How to decode text files from FileSystemReadStream in Pharo 1.4

In Pharo 1.4, I opened FileSystemReadStream in a text file and converted it to String through aFileSystemReadStream contents asString.

My text files are encoded in UTF8 and have these Windows lines (CR LF).

The resulting Pharo lines have two lines in a line of a text file and some strange characters instead of German umlauts such as Ä, Ö, Ü, etc.

How can I decode my text files in Pharo correctly?

+5
source share
1 answer

Do not use FileSystemReadStreams in 1.4, they are not complete and do not work;). Use FileStream instead.

multiByteFileStream := FileStream fileNamed: '/foo/bar.txt'.
multiByteFileStream contents.

MultiByteFileStream, :

multiByteFileStream 
    "possible values are: #cr #lf #crlf"
    lineEndConvention: #cr;
    "set a specific converter, see subclasses of TextConverter"
    converter: UTF8TextConverter new. 
+8

All Articles