主要内容

matlab :: cpplib :: convertutf16stringtoutf8string

将UTF-16字符串转换为UTF-8字符串

描述

std :: string&str convertutf16stringtoutf8string(const std :: u16string&ustr)

将UTF-16字符串转换为UTF-8字符串。由于ASCII是UTF-8编码的子集,因此输出是ASCII内容,只要输入中不存在非ASCII字符。

参数

const std :: u16string&ustr

UTF-16字符串。

返回值

std :: string.

UTF-8字符串。

例外

STD :: Range_Error.

输入不是有效的UTF-16字符串。

例子

将UTF-16字符串转换为UTF-8字符串

自动app = initmatlabapplication(matlabapplicationmode :: Out_of_Process);auto mylib = initmatlablibrary(app,convertutf8stringtoutf16string(“mylib”));std :: u16string ustr = mylib-> feval (“get_const_str”);std :: string str = convertutf16stringtoutf8string(USt);
在R2017B中介绍