MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / _utf8Encode

Function _utf8Encode

packages/ui-default/utils/base64.js:59–76  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

57 },
58
59 _utf8Encode(string) {
60 string = string.replace(/\r\n/g, '\n');
61 let utftext = '';
62 for (let n = 0; n < string.length; n++) {
63 const c = string.charCodeAt(n);
64 if (c < 128) {
65 utftext += String.fromCharCode(c);
66 } else if ((c > 127) && (c < 2048)) {
67 utftext += String.fromCharCode((c >> 6) | 192);
68 utftext += String.fromCharCode((c & 63) | 128);
69 } else {
70 utftext += String.fromCharCode((c >> 12) | 224);
71 utftext += String.fromCharCode(((c >> 6) & 63) | 128);
72 utftext += String.fromCharCode((c & 63) | 128);
73 }
74 }
75 return utftext;
76 },
77
78 _utf8Decode(utftext) {
79 let string = '';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected