MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / encode

Method encode

packages/core/text/text-common.ts:95–106  ·  view source on GitHub ↗
(input = '')

Source from the content-addressed store, hash-verified

93 }
94
95 public encode(input = ''): Uint8Array {
96 // 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
97 // 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
98 const encodedString = input === undefined ? '' : ('' + input).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, encoderReplacer);
99 const len = encodedString.length | 0,
100 result = new Uint8Array(len);
101 for (let i = 0; i < len; i = (i + 1) | 0) {
102 result[i] = encodedString.charCodeAt(i);
103 }
104
105 return result;
106 }
107
108 public toString() {
109 return '[object TextEncoder]';

Callers 4

constructorMethod · 0.95
digestMessageFunction · 0.95
gen_hmacFunction · 0.95
gen_rsa_oaepFunction · 0.95

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected