summaryrefslogtreecommitdiff
path: root/pyuno/source/module/pyuno_util.cxx
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2005-02-24 13:25:40 +0000
committerVladimir Glazounov <vg@openoffice.org>2005-02-24 13:25:40 +0000
commitba678ac52d5162a56dc9d955dffb8697b7d249c5 (patch)
tree1b129ac01ea900fbc9a4a5e85e465b20d2912d26 /pyuno/source/module/pyuno_util.cxx
parentcb9f2168ab78fe7786dabfdf5204c9dcf8a8bc84 (diff)
INTEGRATION: CWS systempython2 (1.2.14); FILE MERGED
2005/02/21 09:35:47 cmc 1.2.14.2: #i41994# dec ref 2005/02/18 08:50:37 cmc 1.2.14.1: #i41994# systempython post pyunofixes1
Diffstat (limited to 'pyuno/source/module/pyuno_util.cxx')
-rw-r--r--pyuno/source/module/pyuno_util.cxx24
1 files changed, 11 insertions, 13 deletions
diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx
index 00c53295cb61..0a51fedf3779 100644
--- a/pyuno/source/module/pyuno_util.cxx
+++ b/pyuno/source/module/pyuno_util.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pyuno_util.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: rt $ $Date: 2004-09-08 16:52:57 $
+ * last change: $Author: vg $ $Date: 2005-02-24 14:25:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -100,16 +100,8 @@ PyRef ustring2PyUnicode( const OUString & str )
#if Py_UNICODE_SIZE == 2
ret = PyRef( PyUnicode_FromUnicode( str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
#else
-#if Py_UNICODE_SIZE == 4
- OString o = OUStringToOString( str, RTL_TEXTENCODING_UCS4 );
- ret = PyRef( PyUnicode_FromUnicode( (Py_UNICODE*)o.getStr(), o.getLength() ), SAL_NO_ACQUIRE );
-#else
-#error Py_UNICODE_SIZE
- OUStringBuffer buf;
- buf.appendAscii( "pyuno string conversion routines can't deal with sizeof(Py_UNICODE) ==" );
- buf.append( (sal_Int32) sizeof( Py_UNICODE ) );
- throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface > ( ) );
-#endif
+ OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8));
+ ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), NULL) , SAL_NO_ACQUIRE );
#endif
return ret;
}
@@ -125,7 +117,13 @@ OUString pyString2ustring( PyObject *pystr )
OUString ret;
if( PyUnicode_Check( pystr ) )
{
- ret = OUString( (sal_Unicode * ) PyUnicode_AS_UNICODE( pystr ) );
+#if Py_UNICODE_SIZE == 2
+ ret = OUString( (sal_Unicode * ) PyUnicode_AS_UNICODE( pystr ) );
+#else
+ PyObject* pUtf8 = PyUnicode_AsUTF8String(pystr);
+ ret = OUString(PyString_AsString(pUtf8), PyString_Size(pUtf8), RTL_TEXTENCODING_UTF8);
+ Py_DECREF(pUtf8);
+#endif
}
else
{