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?

有帮助吗?

解决方案

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.

其他提示

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top