mbstowcs
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <stdlib.h> 中定义
|
||
转换一个多字节字符串数组,该数组的第一个元素是指向
src
它的宽字符表示。转换的字符存储在连续元素指向的数组由dst
。以上len
宽字符写入到目标数组.原文:
Converts a multibyte character string from the array whose first element is pointed to by
src
to its wide character representation. Converted characters are stored in the successive elements of the array pointed to by dst
. No more than len
wide characters are written to the destination array.每个字符被转换为如果由呼叫mbtowc,除了的mbtowc转换状态不受影响。的停止:转换
原文:
Each character is converted as if by a call to mbtowc, except that the mbtowc conversion state is unaffected. The conversion stops if:
- 多字节的空字符被转换并存储.原文:The multibyte null character was converted and stored.
- 遇到一个无效的(在当前的C语言环境)的多字节字符.原文:An invalid (in the current C locale) multibyte character was encountered.
- 下一个宽字符存储将超过
len
.....原文:The next wide character to be stored would exceedlen
.
目录 |
[编辑] 注释
在大多数实现中,这个函数更新一个全局静态mbstate_t类型的对象,因为它处理通过字符串,并不能同时由两个线程调用,mbsrtowcs应在这种情况下,使用.
POSIX指定一个常见的扩展:如果
dst
是一个空指针,这个函数返回的数量范围内的字符将被写入到dst
,如果转换。类似的行为标准mbsrtowcs原文:
POSIX specifies a common extension: if
dst
is a null pointer, this function returns the number of wide characters that would be written to dst
, if converted. Similar behavior is standard for mbsrtowcs.[编辑] 参数
dst | - | 宽字符串将被存储到宽字符数组的指针
原文: pointer to wide character array where the wide string will be stored |
src | - | null结尾的多字节字符串转换的第一个元素的指针
原文: pointer to the first element of a null-terminated multibyte string to convert |
len | - | 指出,DST的宽字符数组中的数
原文: number of wide characters available in the array pointed to by dst |
[编辑] 返回值
成功时,返回的宽字符数,不包括终止L'\0',写入到目标数组.
原文:
On success, returns the number of wide characters, excluding the terminating L'\0', written to the destination array.
转换错误(如果遇到了无效的多字节字符),返回(size_t)-1.
原文:
On conversion error (if invalid multibyte character was encountered), returns (size_t)-1.
[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
将一个狭窄的多字节字符的字符串,宽字符串,给定的状态 原文: converts a narrow multibyte character string to wide string, given state (函数) | |
缩小的多字节字符串转换成宽字符串 原文: converts a wide string to narrow multibyte character string (函数) | |
C++ documentation for mbstowcs
|