跳到主要内容

uint8ArrayToString()

function uint8ArrayToString(u8): string;

Defined in: binary/uint8ArrayToString.ts:14

将Uint8Array转换为UTF-8字符串 使用TextDecoder API进行解码,确保正确处理多字节字符

Parameters

ParameterTypeDescription
u8Uint8Array要转换的Uint8Array实例

Returns

string

解码后的UTF-8字符串 Note: 使用默认的UTF-8编码,不支持其他字符编码

Example

const bytes = new Uint8Array([72, 101, 108, 108, 111]);
uint8ArrayToString(bytes); // 返回 'Hello'