LineEndAuto with EncodedStream

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

LineEndAuto with EncodedStream

Alexander Lazarevic'

most likely I'm missing something here, but automatic lineend detection
does not work for me with encoded streams and I can't see how it ever will.

Just take a text that has CRLF as lineend markers and is saved in
Unicode (UCS-2) encoding. I used the following code to read lines from
such a file in VW:

encodedStream := ('file.txt' asFilename withEncoding: #'UCS-2')
                        readStream lineEndAuto.
encodedStream lineEndConvention. "Evaluates to 3 = LineEndCR"
first := encodedStream upTo: Character cr.
second := encodedStream upTo: Character cr.

The second line starts with a LF (16r0a), because lineEndAuto did fail
to predict the lineend convention used in that file. But how come? It
seems, that in EncodedStream>>lineEndConvention:,
contentsLineEndConvention is used with the unencoded plain bytereading
stream on a twobyte encoded file to look for lineend markers. I guess
this never will work in the case of UCS-2 (or any other >1 byte encoding)?