MCPcopy Create free account
hub / github.com/ampproject/amphtml / utf8DecodeSync

Function utf8DecodeSync

third_party/subscriptions-project/swg.js:3191–3197  ·  view source on GitHub ↗

* Interpret a byte array as a UTF-8 string. * @param {!Uint8Array} bytes * @return {string}

(bytes)

Source from the content-addressed store, hash-verified

3189 * @return {string}
3190 */
3191function utf8DecodeSync(bytes) {
3192 if (typeof TextDecoder !== 'undefined') {
3193 return new TextDecoder('utf-8').decode(bytes);
3194 }
3195 const asciiString = bytesToString(new Uint8Array(bytes));
3196 return decodeURIComponent(escape(asciiString));
3197}
3198
3199/**
3200 * Turn a string into UTF-8 bytes.

Callers 1

decodeInternal_Method · 0.70

Calls 2

bytesToStringFunction · 0.70
decodeMethod · 0.45

Tested by

no test coverage detected