Hi - I’m doing a bit of log file processing with Pharo - and I’ve hit an 
unexpected error and am wondering what the best way to approach it is.

It seems that I have a log file that has unexpected characters, and so my 
readStream loop that reads lines gets an error: "ZnInvalidUTF8: Illegal 
continuation byte for utf-8 encoding”.

For some reason this file (unlike my others) seems to contain characters that 
it shouldn’t - but what is the best way for me to continue processing? Should I 
be opening my files in a different way - or can I resume the error somehow- I’m 
not familiar with this area of Pharo and am after a bit of advice.

My code is like this (and I get the error when doing nextLine)


parseStream: aFileStream with: aBlock
        | line items |
        [ (line := aFileStream nextLine) isNil ]
                whileFalse: [ 
                        items := $/ split: line.
                        items size = 3 ifTrue: [aBlock value: items]]

My stream is created like this:

firmEfs := (pathName , '/' , firmName , '_files') asFileReference.
details parseStream: firmEfs readStream.


Should I be opening the stream a bit differently - or can I catch that encoding 
error and resume it with some safe character?

Thanks for any help.

Tim

Reply via email to