- Source:
Methods
(export, static) fromBytesAutoDetect(datanullable) → {string}
Creates a string from the given buffer, auto-detecting the encoding that is
being used. If it cannot detect the encoding, it will throw an exception.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
BufferSource |
<nullable> |
- Source:
Throws:
Returns:
- Type
- string
(static) fromCharCode(arraynon-null) → {string}
Creates a new string from the given array of char codes.
Using String.fromCharCode.apply is risky because you can trigger stack errors
on very large arrays. This breaks up the array into several pieces to avoid
this.
Parameters:
Name | Type | Description |
---|---|---|
array |
TypedArray |
- Source:
Returns:
- Type
- string
(export, static) fromUTF8(datanullable) → {string}
Creates a string from the given buffer as UTF-8 encoding.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
BufferSource |
<nullable> |
- Source:
Throws:
Returns:
- Type
- string
(export, static) fromUTF16(datanullable, littleEndian, noThrowopt) → {string}
Creates a string from the given buffer as UTF-16 encoding.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
BufferSource |
<nullable> |
|
littleEndian |
boolean | true to read little endian, false to read big. | |
noThrow |
boolean |
<optional> |
true to avoid throwing in cases where we may expect invalid input. If noThrow is true and the data has an odd length, it will be truncated. |
- Source:
Throws:
Returns:
- Type
- string
(export, static) toUTF8(str) → (non-null) {ArrayBuffer}
Creates a ArrayBuffer from the given string, converting to UTF-8 encoding.
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
- Source:
Returns:
- Type
- ArrayBuffer
(export, static) toUTF16(str, littleEndian) → (non-null) {ArrayBuffer}
Creates a ArrayBuffer from the given string, converting to UTF-16 encoding.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | |
littleEndian |
boolean |
- Source:
Returns:
- Type
- ArrayBuffer