[Haskell-beginners] HXT: encoding problem
Derek McLoughlin
derek.mcloughlin at gmail.com
Sat Sep 27 16:13:56 UTC 2014
I just ran this (OS/X + Platform 2014 + hxt 9.3.1.7) and it worked perfectly.
Are you sure that the XML file is actually saved with UTF-8 encoding?
Can you attach it?
On 27 September 2014 16:57, Elias Diem <lists at webconect.ch> wrote:
> Hi guys
>
> I have got the following haskell program:
>
> ------------------------------------------------------
> import Text.XML.HXT.Core
>
> main = do
> xml <- readFile "test_data-small.xml"
> let doc = readString config xml
> res <- runX . xshow $
> doc
> >>>
> getChildren >>> isElem >>> hasName "contacts"
> >>>
> deep isText
> mapM_ putStrLn res
>
> config =
> [ withParseHTML no
> , withWarnings yes
> , withInputEncoding utf8
> , withOutputEncoding utf8
> , withValidate yes
> ]
> ------------------------------------------------------
>
> The file 'test_data-small.xml' contains the following data:
>
> ------------------------------------------------------
> <?xml version='1.0' encoding='UTF-8' ?>
>
> <contacts>
>
> <person>
> <name>
> <firstname>Max</firstname>
> <lastname>Müller</lastname>
> </name>
> </person>
>
> </contacts>
> ------------------------------------------------------
>
> Note the umlaut in the lastname!
>
> If I run the program, I get the following error:
>
> ------------------------------------------------------
> error: UTF-8 encoding error at input position 127: ValueOutOfBounds
> ------------------------------------------------------
>
> Any help is appreciated. Thanks.
>
> --
> Greetings
> Elias
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list