[I18n-sig] Unicode Tutorial (Slow) Progress
Wed, 05 Apr 2000 20:41:30 +0200
Andy Robinson wrote:
> I'm part way through a tutorial at long last. My own work is pretty poor so
> far, but it DOES include Marc-Andre's 'console session' demos at the bottom
> which show the current usage.
> If anyone can suggest topics I should cover (apart from the obvious one of
> using every new features at least once) or simple relevant examples, I'll
> try to work them in over the coming weeks.
Looks great... a bit much exposure, maybe ;-)
Note that the stackable stream example will need a small bit
of updating (the return is wrong -- the API was changed since I
programmed the example):
# Convert Unicode -> UTF-8
(e,d,sr,sw) = codecs.lookup('utf-8')
unicode_to_utf8 = sw(sys.stdout)
# Convert Latin-1 -> Unicode during .write
(e,d,sr,sw) = codecs.lookup('latin-1')
encode = e
decode = d
""" Writes the object's contents encoded to self.stream
and returns the number of bytes written.
data,consumed = self.decode(object,self.errors)
latin1_to_utf8 = StreamRewriter(unicode_to_utf8)
# Now install
sys.stdout = latin1_to_utf8
# All subsequent prints will output Latin-1 strings using UTF-8
print 'Hello World !'
print 'Héllò Wörld !'
Python Pages: http://www.lemburg.com/python/