bos / configurator

A Haskell library supporting flexible, dynamic file-based configuration.
Other
128 stars 27 forks source link

Polish letters encoded as utf-8 in strings are mangled by loading through configurator #30

Open ajuc opened 7 years ago

ajuc commented 7 years ago

I'm new at Haskell, so maybe I misunderstand something, but it seems to me that utf-8 non-latin characters should be handled the same way when loaded from utf-8 file through this library, as they are handled when entered directly in the code. As it is now - they aren't.

Test case:

polishLettersTest :: Assertion
polishLettersTest =
  withLoad "utf8_polish_letters.cfg" $ \cfg -> do
    testString  <- lookup cfg "test"
    assertEqual "string property" testString $ (Just "Zażółć gęślą jaźń" :: Maybe Text)

for file utf8_polish_letters.cfg which contains: test = "Zażółć gęślą jaźń"

On the current version cloned from github today it fails for me with:

polishLettersTest: [Failed]
string property
expected: Just "Za\9532\9565\9500\9474\9532\233\9472\231 g\9472\214\9532\356l\9472\367 ja\9532\9553\9532\228"
 but got: Just "Za\380\243\322\263 g\281\347l\261 ja\378\324"

Maybe I misunderstood the documentation, and utf-8 isn't supposed to be supported? I discovered the problem when I build the sample Spock application https://github.com/agrafix/funblog , and changed the displayed name of the website in configuration to a string with Polish letters.