On 12 March 2018 at 10:03, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi,
do not forget also that there is an entire chapter on FileSystem in here:
http://files.pharo.org/books-pdfs/deep-into-pharo/2013-DeepIntoPharo-EN.pdf
And I particularly recommend everybody dealing with files to read about how to manage encodings in here:
http://files.pharo.org/books-pdfs/entreprise-pharo/2016-10-06-EnterprisePhar...
Cool! I wasn't aware of the section on character encoding, it's probably the best introduction to character encoding I've read. There is one important mistake in the examples. On page 46 it gives the following code: 'encoding-test.txt' asFileReference writeStreamDo: [ :out | (ZnCharacterWriteStream on: out binary encoding: #utf8) nextPutAll: 'Hello'; space; nextPutAll: 'Îλλάδα'; crlf; nextPutAll: 'Les élèves français'; crlf ]. This won't work reliably as #writeStreamDo: (and #readStreamDo:) use MultiByteFileStreams, which are not binary by default. It really should be (in Pharo 7, I haven't checked pharo 6) #binaryWriteStreamDo: and #binaryReadStreamDo:, i.e.: 'encoding-test.txt' asFileReference binaryWriteStreamDo: [ :out | (ZnCharacterWriteStream on: out binary encoding: #utf8) nextPutAll: 'Hello'; space; nextPutAll: 'Îλλάδα'; crlf; nextPutAll: 'Les élèves français'; crlf ]. Cheers, Alistair (I know I should submit a PR for this, but I'm suffering a personal interrupt stack overflow at the moment)