summaryrefslogtreecommitdiff
path: root/pyuno
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
commit500cf712d48c524ebcaa87051ee56ddfb2bc080d (patch)
treeea5f1706e80c37500b4de33c880f99cbd8115c5c /pyuno
parentdfa561dac4ce4d5ad2acf41785b0f13967b5de53 (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')
-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 00c53295c..0a51fedf3 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
{