11 Feb 2013 14:56
Text.JSON and utf8
Martin Hilbig <lists <at> mhilbig.de>
2013-02-11 13:56:04 GMT
2013-02-11 13:56:04 GMT
hi,
tl;dr: i propose this patch to Text/JSON/String.hs and would like to
know why it is needed:
<at> <at> -375,7 +375,7 <at> <at>
where
go s1 =
case s1 of
- (x :xs) | x < '\x20' || x > '\x7e' -> '\\' : encControl x (go xs)
+ (x :xs) | x < '\x20' -> '\\' : encControl x (go xs)
('"' :xs) -> '\\' : '"' : go xs
('\\':xs) -> '\\' : '\\' : go xs
(x :xs) -> x : go xs
i recently stumbled upon CouchDB telling me i'm sending invalid json.
i basically read lines from a utf8 file with german umlauts and send
them to CouchDB using Text.JSON and Database.CouchDB.
$ file lines.txt
lines.txt: UTF-8 Unicode text
lets take 'ö' as an example. i use LANG=de_DE.utf8
ghci tells
> 'ö'
'\246'
(Continue reading)
RSS Feed