Convert arrays to and from different formats.
- bytesToUtf8
- utf8ToBytes
- bytesToHex
- hexToBytes
- utf8ToHex
- hexToUtf8
- isHex
- bytesToBinary
- binaryToBytes
- bytesToBase64
- base64ToBytes
▸ Static
bytesToUtf8(array
, startIndex?
, length?
): string
Encode a raw array to UTF8 string.
Name | Type | Description |
---|---|---|
array |
ArrayLike <number > |
The bytes to encode. |
startIndex? |
number |
The index to start in the bytes. |
length? |
number |
The length of bytes to read. |
string
The array formated as UTF8.
▸ Static
utf8ToBytes(utf8
): Uint8Array
Convert a UTF8 string to raw array.
Name | Type | Description |
---|---|---|
utf8 |
string |
The text to decode. |
Uint8Array
The array.
▸ Static
bytesToHex(array
, startIndex?
, length?
, reverse?
): string
Encode a raw array to hex string.
Name | Type | Description |
---|---|---|
array |
ArrayLike <number > |
The bytes to encode. |
startIndex? |
number |
The index to start in the bytes. |
length? |
number |
The length of bytes to read. |
reverse? |
boolean |
Reverse the combine direction. |
string
The array formated as hex.
▸ Static
hexToBytes(hex
, reverse?
): Uint8Array
Decode a hex string to raw array.
Name | Type | Description |
---|---|---|
hex |
string |
The hex to decode. |
reverse? |
boolean |
Store the characters in reverse. |
Uint8Array
The array.
▸ Static
utf8ToHex(utf8
): string
Convert the UTF8 to hex.
Name | Type | Description |
---|---|---|
utf8 |
string |
The text to convert. |
string
The hex version of the bytes.
▸ Static
hexToUtf8(hex
): string
Convert the hex text to text.
Name | Type | Description |
---|---|---|
hex |
string |
The hex to convert. |
string
The UTF8 version of the bytes.
▸ Static
isHex(value
): boolean
Is the data hex format.
Name | Type | Description |
---|---|---|
value |
string |
The value to test. |
boolean
True if the string is hex.
▸ Static
bytesToBinary(bytes
): string
Convert bytes to binary string.
Name | Type | Description |
---|---|---|
bytes |
Uint8Array |
The bytes to convert. |
string
A binary string of the bytes.
▸ Static
binaryToBytes(binary
): Uint8Array
Convert a binary string to bytes.
Name | Type | Description |
---|---|---|
binary |
string |
The binary string. |
Uint8Array
The bytes.
▸ Static
bytesToBase64(bytes
): string
Convert bytes to base64 string.
Name | Type | Description |
---|---|---|
bytes |
Uint8Array |
The bytes to convert. |
string
A base64 string of the bytes.
▸ Static
base64ToBytes(base64
): Uint8Array
Convert a base64 string to bytes.
Name | Type | Description |
---|---|---|
base64 |
string |
The base64 string. |
Uint8Array
The bytes.