A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-May/024188.html below:

[Python-Dev] getting the UCS-2 representation of a unicode object

[Python-Dev] getting the UCS-2 representation of a unicode object [Python-Dev] getting the UCS-2 representation of a unicode objectFredrik Lundh fredrik@pythonware.com
Sun, 19 May 2002 17:23:28 +0200
andreas wrote:


> 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).

strlen() looks for the first null byte.  in a UCS-2 string containing
ASCII data, every second byte will be a null byte.

> Am I missing something?

trust the macros, and don't use 8-bit functions on 16-bit strings.

</F>





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4