]>
git.saurik.com Git - utf16js.git/blob - utf16.js
89322ec7fc86ea264063ec9761beebb4f75e67cb
1 if (typeof define
!== 'function') { var define
= require('amdefine')(module
) }
3 define(function(require
) {
5 var decode = function(array
, string
) {
6 for (var i
= 0, e
= string
.length
; i
!= e
; ++i
) {
7 var unit
= string
.charCodeAt(i
);
8 var part
= unit
& 0xfc00;
11 else if (part
!= 0xd800)
16 var next
= string
.charCodeAt(i
);
17 if ((next
& 0xfc00) != 0xdc00)
19 array
.push(0x10000 | (unit
& 0x03ff) << 10 | next
& 0x03ff);
26 var encode = function(array
) {
28 for (var i
= 0, e
= array
.length
; i
!= e
; ++i
) {
34 units
.push(0xd800 | (0xffc00 & point
) >> 10, 0xdc00 | 0x03ff & point
);
36 } return String
.fromCharCode
.apply(String
, units
);