From: Jack Jansen Date: Sun, 24 Feb 2002 22:47:43 +0000 (+0000) Subject: Backport of 1.3: X-Git-Tag: v2.2.1c1~181 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87d9d230489408e4fb2b5150503fd5e2e89bcdb0;p=thirdparty%2FPython%2Fcpython.git Backport of 1.3: Added support for unicode strings (utxt). --- diff --git a/Mac/Lib/aepack.py b/Mac/Lib/aepack.py index 161f3eb343a2..331a53ee8b46 100644 --- a/Mac/Lib/aepack.py +++ b/Mac/Lib/aepack.py @@ -88,6 +88,11 @@ def pack(x, forcetype = None): return AE.AECreateDesc('doub', struct.pack('d', x)) if t == StringType: return AE.AECreateDesc('TEXT', x) + if t == UnicodeType: + data = t.encode('utf16') + if data[:2] == '\xfe\xff': + data = data[2:] + return AE.AECreateDesc('utxt', data) if t == ListType: list = AE.AECreateList('', 0) for item in x: @@ -132,6 +137,8 @@ def unpack(desc): return struct.unpack('b', desc.data)[0] if t == typeChar: return desc.data + if t == typeUnicodeText: + return unicode(desc.data, 'utf16') # typeColorTable coerced to typeAEList # typeComp coerced to extended # typeData returned as unknown