Unicode File I/O Grief
Martin v. Loewis
martin at v.loewis.de
Fri May 17 02:58:03 EDT 2002
Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk> writes:
> >I recommend to do
> >
> >codecs.open('C:\\odd.txt', 'wb', encoding="utf-8").write(ucString)
> >
> >or
> >
> >file('C:\\odd.txt', 'wb').write(ucString.encode("utf-8"))
> >
>
> But surely these translate the string before writing it?
>
> I don't want it translated I want to see EXACTLY what's in there as it
> stands.
If, by "see", you mean "with my eyes", then the best way is to do
file('C:\\odd.txt', 'wb').write(repr(ucString))
This also translates the string; there is no way to "see" the Unicode
object, except perhaps by viewing the computer's hardware under an
electron microscope...
Regards,
Martin
More information about the Python-list
mailing list