Pergunta

I am reading a .json file from disk using Windows.Storage.FileIO.readTextAsync. All is fine until I put some non english letters in the file, like Æ Å Ø

The error I get is (rough translation from Danish language): WinRT: No mapping for the Unicode character exists in the target multi-byte code page.

any idea how to read those chars in WinJs?

Foi útil?

Solução

I found the problem.

when I created the file manually with notepad I set it to type ANSII instead of utf8. I reopened the file -> save as and the changed the type and overwrote it.

Outras dicas

You may be able to solve this by changing the encoding from the default (Utf8) to Utf16. The readTextAsync method accepts a second parameter which is a UnicodeEncoding flag:

Windows.Storage.FileIO.readTextAsync(
    file,
    Windows.Storage.Streams.UnicodeEncoding.utf16LE
).done( ... );

Or if you need to, you can use utf16BE flag (see link above).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top