Unicode support

Hye-Shik Chang hyeshik at gmail.com
Sat Aug 7 12:31:35 CEST 2004


On 6 Aug 2004 07:57:44 -0700, Richy2004 <richard.scothern at gmail.com> wrote:
> code:
> import sys,codecs
> file = codecs.open("accountmgr_words_arb.txt", "r", "utf-16")
> print (file.readline())
> 
> output:
> File "./test.py", line 5, in ?
> print (file.readline())
> File "C:\Python23\lib\codecs.py", line 384, in readline
> return self.reader.readline(size)
> File "c:\Python23\lib\encodings\utf_16.py", line 57, in readline
> raise NotImplementedError, '.readline() is not implemented for
> UTF-16'
> NotImplementedError: .readline() is not implemented for UTF-16
> 

UTF-16 readline is being supported by CJKCodecs 1.1. :)

>>> import codecs
>>> codecs.open("u16test", "r", "cjkcodecs.utf-16")
<open file 'u16test', mode 'rb' at 0x81ab7e0>
>>> _.readline()
u'\u25ce \ud30c\uc774\uc36c(Python)\uc740 \ubc30\uc6b0\uae30
\uc27d\uace0, \uac15\ub825\ud55c \ud504\ub85c\uadf8\ub798\ubc0d
\uc5b8\uc5b4\uc785\ub2c8\ub2e4. \ud30c\uc774\uc36c\uc740\n'


Hye-Shik



More information about the Python-list mailing list