Alex Martelli wrote: > Fuzzyman <[EMAIL PROTECTED]> wrote: > ... > > I can't open with a codec unless an encoding is explicitly supplied. I > > still want to detect UTF16 even if the encoding isn't specified. > > > > As I said, I ought to test this... Without metadata I wonder how Python > > determines it ? > > It doesn't. Python doesn't even try to guess: nor would any other > sensible programming language. >
Right, so opening in "rU" mode and testing the 'newline' attribute *won't* work for UTF16 encoded files. (Which was what I was asking.) I'll have to read, determine encoding, decode, then *either* use my code to determine line endings *or* use ``splitlines(True)``. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > > Alex -- http://mail.python.org/mailman/listinfo/python-list