Skip to content
Snippets Groups Projects
Commit 1b23cfac authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add script to convert from utf8 to internal (utf16) representation.

parent eaf81457
No related branches found
No related tags found
No related merge requests found
// $Id: utf8_cp437.js,v 1.6 2019/07/24 22:05:29 rswindell Exp $
function utf8_utf16(uni)
{
return uni.replace(/[\xc0-\xfd][\x80-\xbf]+/g, function(ch) {
var i;
var uc = ch.charCodeAt(0);
for (i=7; i>0; i--) {
if ((uc & 1<<i) == 0)
break;
uc &= ~(1<<i);
}
for (i=1; i<ch.length; i++) {
uc <<= 6;
uc |= ch.charCodeAt(i) & 0x3f;
}
return String.fromCharCode(uc);
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment