MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / ucs2decode

Function ucs2decode

public/javascripts/socket.io.js:6339–6363  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

6337
6338 // Taken from https://mths.be/punycode
6339 function ucs2decode(string) {
6340 var output = [];
6341 var counter = 0;
6342 var length = string.length;
6343 var value;
6344 var extra;
6345 while (counter < length) {
6346 value = string.charCodeAt(counter++);
6347 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
6348 // high surrogate, and there is a next character
6349 extra = string.charCodeAt(counter++);
6350 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
6351 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
6352 } else {
6353 // unmatched surrogate; only append this code unit, in case the next
6354 // code unit is the high surrogate of a surrogate pair
6355 output.push(value);
6356 counter--;
6357 }
6358 } else {
6359 output.push(value);
6360 }
6361 }
6362 return output;
6363 }
6364
6365 // Taken from https://mths.be/punycode
6366 function ucs2encode(array) {

Callers 2

wtf8encodeFunction · 0.85
wtf8decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected