]>
git.saurik.com Git - utf16js.git/blob - utf16.js
e42f42f34c757e64dad1ddf1b1e2874ba6cbe38f
1 if (typeof define
!== 'function') { var define
= require('amdefine')(module
) }
3 define(function(require
) {
5 var decode = function(string
, points
) {
6 if (typeof points
=== "undefined")
9 for (var i
= 0, e
= string
.length
; i
!= e
; ++i
) {
10 var unit
= string
.charCodeAt(i
);
11 var part
= unit
& 0xfc00;
14 else if (part
!= 0xd800)
19 var next
= string
.charCodeAt(i
);
20 if ((next
& 0xfc00) != 0xdc00)
22 points
.push(0x10000 | (unit
& 0x03ff) << 10 | next
& 0x03ff);
29 var encode = function(points
) {
31 for (var i
= 0, e
= points
.length
; i
!= e
; ++i
) {
32 var point
= points
[i
];
37 units
.push(0xd800 | (0xffc00 & point
) >> 10, 0xdc00 | 0x03ff & point
);
39 } return String
.fromCharCode
.apply(String
, units
);