[Haskell-beginners] HXT: encoding problem

Elias Diem lists at webconect.ch
Sat Sep 27 15:57:08 UTC 2014


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




More information about the Beginners mailing list