I've got the unicode blues

Francis Meyvis francis.meyvis at sonycom.com
Tue Mar 5 05:59:37 EST 2002


> lines = ReadLinesFromAnything("test.reg")
> file = open("test.out","wb")
> file.write(codecs.BOM_LE)
> for line in lines:
>     file.write(line.encode("utf-16le"))
> file.close()
>
> The LE/BE codecs don't write a BOM, so they operate nicely using
> sequential write. In fact, this is what the UTF-16 codec does: it
> first writes the BOM, then writes the data in the chosen endianness.
>
> > - *much* better support for UNICODE Textfiles in python
> > - a *much* better documentation on this in python.
> >
> > So now I already feel much better :)

These will generate a single starting BOM
in the 2byte unicode file

f = codecs.open("test.out", "w", "utf-16")
for l in lines:
    f.write(l)
f.close()


---
Kind regards, best wishes,
francis meyvis






More information about the Python-list mailing list