(str: string)
| 35 | * @returns The corresponding Uint8Array. |
| 36 | */ |
| 37 | export function StringToUint8Array(str: string): Uint8Array { |
| 38 | const arr: Uint8Array = new TextEncoder().encode(str); |
| 39 | const resArr = new Uint8Array(arr.length + 1); |
| 40 | for (let i = 0; i < arr.length; ++i) { |
| 41 | resArr[i] = arr[i]; |
| 42 | } |
| 43 | resArr[arr.length] = 0; |
| 44 | return resArr; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Convert Uint8array to string. |
no test coverage detected
searching dependent graphs…