主要内容

native2unicode

将数值字节转换为 Unicode 字符

    说明

    unicodestr = native2unicode(bytes) 使用默认编码方案将字节的数值向量转换为对应的 Unicode® 字符。输出 unicodestr 是字符向量,其数组形状与 bytes 相同。

    如果您将 bytes 指定为字符向量或字符串标量,则该函数返回相同的文本值。

    示例

    unicodestr = native2unicode(bytes,encoding) 使用指定的编码方案转换字节的数值向量。

    示例

    示例

    全部折叠

    使用默认编码方案将字节向量转换为 Unicode 字符。

    bytes = [104 101 108 108 111];
    unicodestr = native2unicode(bytes)
    unicodestr = 
    'hello'
    

    使用 latin1 编码方案将字节数组转换为 Unicode 字符。

    bytes = [255 254 104 0 101 0 108 0 108 0 111 0];
    unicodestr = native2unicode(bytes,"UTF-16")
    unicodestr = 
    'hello'
    

    输入参数

    全部折叠

    字节,指定为数值向量,其中每个元素必须在范围 [0,255] 内。

    数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Unicode 编码方案,指定为包含编码方案名称的字符串标量或字符向量。一些示例编码方案为:'UTF-8''latin1''US-ASCII''Shift_JIS'。此函数接受由 International Components for Unicode (ICU) 库定义的编码方案,有关详细信息,请参阅 ICU 文档中的转换

    输出参量

    全部折叠

    Unicode 文本,以字符向量形式返回。

    提示

    • 默认编码方案可能与从文件读取的字节的编码方案不匹配。

    扩展功能

    全部展开

    版本历史记录

    在 R2006a 之前推出

    另请参阅