0

I'm trying to add a Chinese localisation to a scaffolded Yesod site. I have a zh.msg message file saved as UTF-8 format using Notepad in Windows, but when I run cabal install in the project directory, I get this:

Handler\Home.hs:15:11:
    Not in scope: data constructor `MsgHello'
    Perhaps you meant `Msg<stderr>: hPutChar: invalid argument (invalid character)

The line in question is where I render my homepage:

$(widgetFile "homepage")

I changed both message files to be Unicode formatted instead of UTF-8, and get this message instead:

Foundation.hs:1:1:
    Exception when trying to run compile-time code:
    Cannot decode byte '\xff': Data.Text.Encoding.Fusion.streamUtf8: invalid UTF-8 stream

So I guess UTF-8 is the way to go... somehow.

(I'm using Notepad because I haven't set up gVim to render Unicode characters. It's apparently a bit of a feat.)

Daniel Buckmaster
  • 7,108
  • 6
  • 39
  • 57

1 Answers1

0

When I went to commit my changes I discovered the issue. The diff for my English file looked like this:

-Hello: Hello
+<U+FEFF>Hello: Hello

I guess notepad added the character in, and it was working its way into the Haskell code. I solved it using vim according to this answer.

Community
  • 1
  • 1
Daniel Buckmaster
  • 7,108
  • 6
  • 39
  • 57