[Python-Dev] getting the UCS-2 representation of a unicode object
Andreas Jung
andreas@andreas-jung.com
Sun, 19 May 2002 10:35:19 -0400
Sounds reasonable..but since Py_ParseTuple() only applies to function
arguments
it can not be used to convert a unicode object to UCS-2. So what is the
easiest
way to get the UCS-2 representation? PyUnicode_AS_DATA() returns for
u'computer'
a char * with strlen()==1, however PyUnicode_GET_DATA_SIZE() on the
same string returns 16 (looks fine for the two byes encoding of UCS-2). Am I
missing
something?
Andreas
----- Original Message -----
From: "M.-A. Lemburg" <mal@lemburg.com>
To: "Andreas Jung" <andreas@andreas-jung.com>
Cc: <python-dev@python.org>
Sent: Sunday, May 19, 2002 09:25
Subject: Re: [Python-Dev] getting the UCS-2 representation of a unicode
object
> Andreas Jung wrote:
> > Py_BuildValue() allows the usage of "u" or "u#" to convert UCS-2
> > data into a Python unicode object, however Py_ParseTuple() converts
> > a unicode object to UTF-16. Is this an error in the documentation
> > or why is there a asymmmetry in the API?
>
> Sounds like a documentation bug: it should be UCS-2 since that's
> what's used as internal data represenation in narrow Unicode
> builds (the default).
>
> --
> Marc-Andre Lemburg
> CEO eGenix.com Software GmbH
> ______________________________________________________________________
> Company & Consulting: http://www.egenix.com/
> Python Software: http://www.egenix.com/files/python/
>