On 18 Jul 2017, at 15:42, Cyril Ferlicot <cyril.ferlicot@gmail.com> wrote:
Hi,
I did a refactoring in Moose in order to use the encoding detector that Sven did some weeks ago while reading a file.
With the latest stable version of ZincHTTPComponent, I can get the encoding like this:
fileReference binaryReadStreamDo: [ :in | (ZnCharacterEncoder detectEncoding: in upToEnd) ]
Since we need to read the files a lot, I save the identifier of the encoder using the #identifier method. Then when I read I just want to get the TextConverter corresponding to the encoder in order to read the stream.
The problem is that in the case of a file encoded in ISO-8859-1, my instance of ZnSimplifiedByteEncoder return 'iso88591' as identifier and Latin1TextConverter does not have this encoding name in its possibilities. Only 'iso-8859-1'.
Should we add 'iso88591' to the Latin1TextConverter? If yes, could we backport this to Pharo 6 please?
These are all aliases [ see: https://en.wikipedia.org/wiki/ISO/IEC_8859-1 ]. So you could add it, yes But why use TextConverter at all ? You could keep on using the alternative (more modern, cleaner) ZnCharacterEncoder hierarchy. Just open your streams binary and wrap a ZnCharacterReadStream around them with the encoding of your choice. fileReference binaryReadStreamDo: [ :in | (ZnCharacterReadStream on: in encoding: #latin1) ... ]
-- Cyril Ferlicot https://ferlicot.fr
http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France