MCPcopy Create free account
hub / github.com/Moli-X/Resources / cb_utob

Function cb_utob

Script/Parser.js:3003–3021  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

3001 var fromCharCode = String.fromCharCode;
3002 // encoder stuff
3003 var cb_utob = function (c) {
3004 if (c.length < 2) {
3005 var cc = c.charCodeAt(0);
3006 return cc < 0x80 ? c
3007 : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
3008 + fromCharCode(0x80 | (cc & 0x3f)))
3009 : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
3010 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
3011 + fromCharCode(0x80 | (cc & 0x3f)));
3012 } else {
3013 var cc = 0x10000
3014 + (c.charCodeAt(0) - 0xD800) * 0x400
3015 + (c.charCodeAt(1) - 0xDC00);
3016 return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
3017 + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
3018 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
3019 + fromCharCode(0x80 | (cc & 0x3f)));
3020 }
3021 };
3022 var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
3023 var utob = function (u) {
3024 return u.replace(re_utob, cb_utob);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected