Change JavaScript string encoding
At the moment I have a large JavaScript string I'm attempting to write to
a file, but in a different encoding (ISO-8859-1). I was hoping to use
something like downloadify. Downloadify only accepts normal JavaScript
strings or base64 encoded strings.
Because of this, I've decided to compress my string using JSZip which
generates a nicely base64 encoded string that can be passed to
downloadify, and downloaded to my desktop. Huzzah! The issue is that the
string I compressed, of course, is still the wrong encoding.
Luckily JSZip can take a Uint8Array as data, instead of a string. So is
there any way to convert a JavaScript string into a ISO-8859-1 encoded
string and store it in a Uint8Array?
Alternatively, if I'm approaching this all wrong, is there a better
solution all together? Is there a fancy JavaScript string class that can
use different internal encodings?
No comments:
Post a Comment