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-January/019298.html below:

[Python-Dev] unicode/string asymmetries

[Python-Dev] unicode/string asymmetries [Python-Dev] unicode/string asymmetriesFredrik Lundh fredrik@pythonware.com
Wed, 9 Jan 2002 10:02:12 +0100
thomas wrote:

> Hehe, I don't want to put objects in structures, I just want to buid
> structures containing "Unicode strings".

there is no such thing.

what you want is a binary buffer with an *encoded*
unicode string.

to get one, figure out what encoding you need (probably
utf-16-le), convert the string to a byte string using the
encode method, and store that byte string in your struct.

def wu(str):
    # encode unicode string for win32 apis
    return str.encode("utf-16-le")

struct.pack("32s", wu(u"VS_VERSION_INFO"))

>
> struct.pack("32s", str(buffer(u"VS_VERSION_INFO")))

that's evil: you're assuming that Python will always use the
same internal representation for unicode strings.  that's not
the case.

</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