B
Bengt Richter
I couldn't find one. (Hi Martin ;-)
Regards,
Bengt Richter
Regards,
Bengt Richter
Bengt said:I couldn't find one.
I couldn't find one. (Hi Martin ;-)
Martin said:No, there is no need to have one (neither is there a need to have one
for plain ASCII files): The end-of-file is when the file ends. Most
operating systems support a notion of a "file size", and the file ends
when file-size bytes have been consumed.
Why Microsoft decided to use ctr-z in text files is beyond me, it does
not fulfil any useful function...
Bob said:On Win 2K the Task Scheduler writes a log file that appears to be
encoded. The first line is:
'\xff\xfe"\x00T\x00a\x00s\x00k\x00
\x00S\x00c\x00h\x00e\x00d\x00u\x00l\x00e\x00r\x00
\x00S\x00e\x00r\x00v\x00i\x00c\x00e\x00"\x00\r\x00\n'
At said:I wrote that into a file, and used the 'file' utility from Cygwin, which
tells me:
$ file t
t: Little-endian UTF-16 Unicode character data, with CR line terminators
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"
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")
If the file starts with a UTF-16 marker (either little or big endian) it
will be read correctly. If it doesn't start with either marker reading from
it will throw a UnicodeError.
Bob said:[...] UniCodeError: UTF-16 decoding error: truncated data
>>> unicode(s[:-1], "utf-16") u'"Task Scheduler Service"\r'
>>>
Duncan said: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")
Are you doing readline on the unicode file?Bob said: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")
If the file starts with a UTF-16 marker (either little or big endian) it
will be read correctly. If it doesn't start with either marker reading
from
it will throw a UnicodeError.
Interesting error:
UniCodeError: UTF-16 decoding error: truncated data
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.