Unicode File I/O Grief

Andreas Jung andreas at zope.com
Thu May 16 15:23:17 EDT 2002


Python will try to convert the unicode string to a byte stream
using the default encoding. This might fail when the default
encoding is not set properly. Instead it is better to convert
the unicode string using a valid unicode encoding like UTF-8.

-aj

----- Original Message ----- 
From: "Terry Reedy" <tjreedy at udel.edu>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Thursday, May 16, 2002 15:10
Subject: Re: Unicode File I/O Grief


> 
> "Dale Strickland-Clark" <dale at riverhall.NOTHANKS.co.uk> wrote in
> message news:a1u7eu0l24gbvutju856kgcj688avdcphm at 4ax.com...
> > I simply want to do the following:
> >
> > file('C:\\odd.txt', 'wb').write(ucString)
> >
> > ...so that I can examine the contents of this (rather long) Unicode
> > string in an editor.
> >
> > Can I write it to a file?
> 
> Try it and see.  The interactive interpreter makes it trivial to
> investigate such questions oneself.
> 
> Terry J. Reedy
> 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 






More information about the Python-list mailing list