mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 05:06:49 +03:00
py3k: Add true Unicode support to OleFileIO
The day has arrived when Python provides an official way to handle Unicode strings.
This commit is contained in:
parent
fc035814bd
commit
3a665a7835
|
@ -37,7 +37,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import StringIO
|
import StringIO
|
||||||
|
import sys
|
||||||
|
|
||||||
def i16(c, o = 0):
|
def i16(c, o = 0):
|
||||||
return ord(c[o])+(ord(c[o+1])<<8)
|
return ord(c[o])+(ord(c[o+1])<<8)
|
||||||
|
@ -327,9 +327,12 @@ class OleFileIO:
|
||||||
def _unicode(self, s):
|
def _unicode(self, s):
|
||||||
# Map unicode string to Latin 1
|
# Map unicode string to Latin 1
|
||||||
|
|
||||||
# FIXME: some day, Python will provide an official way to handle
|
if sys.version_info >= (3,0):
|
||||||
# Unicode strings, but until then, this will have to do...
|
# Provide actual Unicode string
|
||||||
return filter(ord, s)
|
return s.decode('utf-16')
|
||||||
|
else:
|
||||||
|
# Old version tried to produce a Latin-1 str
|
||||||
|
return s.decode('utf-16').encode('latin-1', 'replace')
|
||||||
|
|
||||||
def loaddirectory(self, sect):
|
def loaddirectory(self, sect):
|
||||||
# Load the directory. The directory is stored in a standard
|
# Load the directory. The directory is stored in a standard
|
||||||
|
|
Loading…
Reference in New Issue
Block a user