read(1) returns string of length 2

Skip Montanaro skip at
Wed Nov 24 13:20:34 CET 2004

    wolfgang> I'm trying to read (japanese) chars from a file. While doing
    wolfgang> so I encounter that a char with length 2 is returned. Is this
    wolfgang> to be expected or is there something wrong?

I believe it's to be expected.  You opened the file with, so
your basic unit of operation will be a Unicode character, not a byte.

    wolfgang> My naive assumption was that returns always a char
    wolfgang> of length 1 (or zero).

If you simply used the builtin open() to open the file that would be true.


More information about the Python-list mailing list