MCPcopy Create free account
hub / github.com/tensorflow/tfjs / encode

Method encode

tfjs-react-native/src/platform_react_native.ts:147–153  ·  view source on GitHub ↗

* Encode the provided string into an array of bytes using the provided * encoding.

(text: string, encoding: string)

Source from the content-addressed store, hash-verified

145 * encoding.
146 */
147 encode(text: string, encoding: string): Uint8Array {
148 // See https://www.w3.org/TR/encoding/#utf-16le
149 if (encoding === "utf-16") {
150 encoding = "utf16le";
151 }
152 return new Uint8Array(Buffer.from(text, encoding as BufferEncoding));
153 }
154 /** Decode the provided bytes into a string using the provided encoding. */
155 decode(bytes: Uint8Array, encoding: string): string {
156 // See https://www.w3.org/TR/encoding/#utf-16le

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected