MCPcopy Create free account
hub / github.com/cryptii/cryptii / codePointsFromBytes

Method codePointsFromBytes

src/TextEncoder.js:149–157  ·  view source on GitHub ↗

* Decodes Unicode code points from bytes using given encoding. * @param {Uint8Array} bytes * @param {String} [encoding='utf8'] * @throws {Error} Throws an error if given encoding is not supported. * @throws {TextEncodingError} Throws an error if given bytes are malformed. * @return {n

(bytes, encoding = 'utf8')

Source from the content-addressed store, hash-verified

147 * @return {number[]} Array of Unicode code points
148 */
149 static codePointsFromBytes (bytes, encoding = 'utf8') {
150 switch (encoding) {
151 case 'utf8':
152 return TextEncoder._decodeCodePointsFromUTF8Bytes(bytes)
153 default:
154 throw new Error(
155 `Decoding from '${encoding}' is currently not supported.`)
156 }
157 }
158
159 static _encodeCodePointsToUTF8Bytes (codePoints) {
160 // In the worst case every code point needs to be represented by 4 bytes

Callers 2

TextEncoder.jsFile · 0.80
getCodePointsMethod · 0.80

Calls 1

Tested by

no test coverage detected