snowkit / snow

A low level cross platform framework for Haxe. Mac, Windows, Linux, Android, iOS, WebGL.
http://snowkit.org/snow
MIT License
133 stars 35 forks source link

Change charset in XHR header to UTF-8 #61

Closed smvilar closed 9 years ago

smvilar commented 9 years ago

Fixes reading UTF-8 text files in web target.

ruby0x1 commented 9 years ago

hmm, there is a reason this is set this way, let me find the link

smvilar commented 9 years ago

I can make a running example of the issue if you need. Maybe the charset should be parameterized for the case is text or binary?

ruby0x1 commented 9 years ago

The issue is two way, for example with png images :

Specifically, the first byte 0x89 when round-tripped through utf-8 gets converted into the replacement character 0xffd and comes back (utf-8 encoded) as 0xef 0xbf 0xbd.

This breaks loading them and other binary files and the x-user-defined mime override allows this to work otherwise. I will think over the best option for the API because it's currently platform specific, but either way it shouldn't be hardcoded.

btw, what end point on the api are you calling to face the issue? loadText or direct etc?

smvilar commented 9 years ago

I'm using loadJSON and loadText

ruby0x1 commented 9 years ago

Updated all internals to use non-binary flag for text loading, through an options flag. Should resolve it, let me know!