Fix lack of encoding to UTF-8#6
Conversation
|
Adding a dependency on I haven't looked closely at the browser support for this API, but it looks like it's "pretty much anything except IE" which, for the purposes of the Svelte REPL, is certainly acceptable. |
|
It's possible to manually encode, e.g. https://gist.github.com/joni/3760795 (though not sure how to be about the license) |
|
I've looked for packages for converting string to UTF-8 and stopped on utf8-bytes - it does only what we need, small, has MIT license, and I'm ok with its implementation. |
Mostly it's PR to fix https://github.com/sveltejs/svelte/issues/3323
I think the issue should be fixed here because this library generates archives with content that doesn't match the one passed to the input.
The first thing is that the library doesn't convert Unicode char codes to UTF-8's.
The second is that for surrogate characters, the lib is ignoring the second character of the pair.
For both cases, added tests with checking of the unzipped content.
Here are logs of new tests without encoding the input text:
Test 8 checks encoding of characters above 0x7F and the first letters of the Cyrillic alphabet were turned to numbers XD
Test 9 checks encoding of surrogate characters (used to display symbols above 0xFFFF) - the sample symbol was turned to \0.