5.4.1字符串编码

 
:native_bytes= unicode2native (utf8_str,codepage)
:native_bytes= unicode2native (utf8_str)

转换UTF-8字符串utf8_str到字节流使用codepage.

字符向量utf8_str转换为字节流native_bytes使用给定的代码页codepage.字符串codepage必须是有效代码页的标识符。有效代码页的示例如下"ISO-8859-1","Shift-JIS""UTF-16"。有关支持的代码页的列表,详见https://www.gnu.org/software/libiconv如果codepage如果省略或为空,则使用系统默认代码页。

如果任何字符无法map到代码页codepage,它们被替换为该代码页的适当替换序列。

详见: native2unicode.

广告
 
:utf8_str= native2unicode (native_bytes,codepage)
:utf8_str= native2unicode (native_bytes)

转换字节流native_bytes使用转换为UTF-8codepage.

向量中的数字native_bytes四舍五入并剪裁为0到255之间的整数。然后,这个字节流被map到字符串给出的代码页中codepage并在字符串中返回utf8_strOctave使用UTF-8作为其内部编码。字符串codepage必须是有效代码页的标识符。有效代码页的示例如下"ISO-8859-1","Shift-JIS""UTF-16"。有关支持的代码页的列表,详见https://www.gnu.org/software/libiconv如果codepage省略或为空,则使用系统默认代码页。

如果native_bytes是字符串向量,则按原样返回。

详见: unicode2native.

广告

版权所有 © 2024-2025 Octave中文网

ICP备案/许可证号:黑ICP备2024030411号-2