Read file that starts with '\xff\xfe'
Peter Hansen
peter at engcorp.com
Mon Sep 8 11:21:25 EDT 2003
Duncan Booth wrote:
>
> Bob Gailer <bgailer at alum.rpi.edu> wrote in
> news:mailman.1063025195.15280.python-list at python.org:
>
> > That's a good start. I presume I need to use codecs.open(filename,
> > mode[, encoding[, errors[, buffering]]]) to read the file. What is the
> > actual value of the "encoding[" parameter for "Little-endian UTF-16
> > Unicode character data, with CR line terminators"
>
> Try:
>
> myFile = codecs.open(filename, "r", "utf16")
I don't do unicode, but might you not want "rb" instead of just "r"
in the above? Does that argument apply to the low-level "open" or
to the codec open? In other words, when would CR-LF translation be
happening if you specified just "r"?
-Peter
More information about the Python-list
mailing list