Class TextEncoder
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The TextEncoder interface enables you to character encoding a JavaScript string using UTF-8.
[Value("TextEncoder")]
public class TextEncoder
- Inheritance
-
TextEncoder
- Inherited Members
Remarks
-The TextDecoder interface describing the inverse operation.
Constructors
TextEncoder()
The TextEncoder() constructor returns a newly created TextEncoder object.
public TextEncoder()
Remarks
-The TextEncoder interface it belongs to.
Methods
Encode(string)
The TextEncoder.encode() method takes a string as input, and returns a Global_Objects/Uint8Array containing the string {{glossary("character encoding", "encoded")}} using {{glossary("UTF-8")}}.
[Value("encode")]
public Uint8Array Encode(string input = null)
Parameters
inputstring
Returns
- Uint8Array
A Uint8Array object containing the UTF-8 encoding of the input string.
Remarks
-The TextEncoder interface it belongs to.
EncodeInto(string, Uint8Array)
The TextEncoder.encodeInto() method takes a string to encode and a destination Uint8Array to put resulting {{glossary("UTF-8")}} encoded text into, and returns an object indicating the progress of the encoding.
This is potentially more performant than the Encode(string) method — especially when the target buffer is a view into a Wasm heap.
[Value("encodeInto")]
public TextEncoderEncodeIntoResult EncodeInto(string source, Uint8Array destination)
Parameters
sourcestringdestinationUint8Array
Returns
- TextEncoderEncodeIntoResult
An object, which contains two members:
Remarks
-The TextEncoder interface it belongs to.
-Encode(string)