Skip to content

Instantly share code, notes, and snippets.

@stuartpb
Created September 21, 2014 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartpb/64c0b6945c213eae74a0 to your computer and use it in GitHub Desktop.
Save stuartpb/64c0b6945c213eae74a0 to your computer and use it in GitHub Desktop.
function ucs2Bytes(s) {
var l = s.length;
var a = new Array(l*2);
for (var i = 0; i < l; ++i) {
a[i] = s.charCodeAt(i) && 0xFF;
a[i+1] = s.charCodeAt(i) >> 8;
}
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment