Open noahsilas opened 7 years ago
Whoops, sorry, meant to respond.
As long as the polyfill doesn't require any build steps or pulling in additional libraries (e.g. some "require" variant), then I'd consider it. You may want to sketch out your idea first to discuss in more detail.
Also, I should mention that you can implement UTF-16 encoding far more efficiently than the polyfill does:
// assume bytes = Uint8Array of byte.
// also assumes array buffers are little endian - may need to byte-swap otherwise
var string = new Uint16Array(bytes.buffer).map(cp => String.fromChar(cp)).join('');
I'm working on a tool to generate a CSV export of some data in a browser, and unfortunately, the encoding situation is a bit of a mess. TL/DR, it seems that the best outcome results in a tab separated, utf-16-le encoded file. [1][2]
I'm interested in using this package not as a polyfill, but by directly loading it when I need to perform that encoding. Would you be open to a PR that moved the core encoding functionality into a standalone module, and implementing the polyfill as a consumer of that standalone library?
[1] https://donatstudios.com/CSV-An-Encoding-Nightmare [2] http://terminaln00b.ghost.io/excel-just-save-it-as-a-csv-noooooooo/