bulat.ziganshin at gmail.com
Fri Feb 1 09:36:54 EST 2008
Friday, February 1, 2008, 4:29:02 PM, you wrote:
>> may be it's too draconian restriction but i proposed just to use new
>> library in the new code.
> For backwards compatibility, I agree it would be preferable to retain
> the current default implementation, but opinions appear to differ.
the problem is not abstract "backward compatibility" but programs that
switches from the old lib to the new one. they should get exactly the
old services for old names - in order to not rewrite program
new programs what need new behavior just need to import new interface
which may provide UTF-8 encoding for text files by default
>> f <- openFile "name"
>> content <- readLine f -- read first line using Latin-1
>> f' <- withEncoding (lookup content) f
>> str <- readLine f' -- read second line using encoding given on first line
> This is clear enough, but for the BOM-dependent decoding, you may have
> to do the equivalent of having the next call to 'readLine' re-read the
> first line instead.
it's not a problem - file pointer is retained in f and f' just
interprets the bytes it read:
f <- openFile "name"
bom <- readBytes 4 f -- read first 4 bytes
f' <- withEncoding (lookup bom) f
str <- readLine f' -- read first line using BOM encoding
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Libraries