Encoding
16 Dec 20252 minutes to read
Encoding class: Contains the details about encoding type, whether to write a Unicode byte order mark (BOM).
let encoding : Encoding = new Encoding();
encoding.type = 'Utf8';
encoding.getBytes('Encoding', 0, 5);Properties
includeBom boolean
Gets a value indicating whether to write a Unicode byte order mark.
type EncodingType
Gets the encoding type.
Methods
destroy
Clears the encoding instance.
Returns void
getByteCount
Calculates the number of bytes produced by encoding the characters in the specified string
| Parameter | Type | Description |
|---|---|---|
| chars | string |
The string containing the set of characters to encode |
Returns number
getBytes
Encodes a set of characters from the specified string into the ArrayBuffer.
| Parameter | Type | Description |
|---|---|---|
| s | string |
The string containing the set of characters to encode. |
| charIndex | number |
The index of the first character to encode. |
| charCount | number |
The number of characters to encode. |
Returns ArrayBuffer
getString
Decodes a sequence of bytes from the specified ArrayBuffer into a string.
| Parameter | Type | Description |
|---|---|---|
| bytes | ArrayBuffer |
The ArrayBuffer containing the sequence of bytes to decode. |
| index | number |
The index of the first byte to decode. |
| count | number |
The number of bytes to decode. |
Returns string