wcstombs
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <stdlib.h> 中定义
|
||
从阵列中的第一元件被指出通过
src
其窄的多字节表示开始在初始变速状态的宽字符的序列转换。转换的字符存储在连续元素的char数组所指向的dst
。不超过len
字节写入到目标数组.原文:
Converts a sequence of wide characters from the array whose first element is pointed to by
src
to its narrow multibyte representation that begins in the initial shift state. Converted characters are stored in the successive elements of the char array pointed to by dst
. No more than len
bytes are written to the destination array.每个字符转换为如果通过调用wctomb,除了wctomb的转换状态不受影响。的停止:转换
原文:
Each character is converted as if by a call to wctomb, except that the wctomb's conversion state is unaffected. The conversion stops if:
- 空字符转换和存储.原文:The null character was converted and stored.
- 一个wchar_t发现不符合当前的C语言环境中的有效字符.原文:A wchar_t was found that does not correspond to a valid character in the current C locale.
- 接下来的多字节字符存储将超过
len
.原文:The next multibyte character to be stored would exceedlen
.
目录 |
[编辑] 注释
在大多数实现中,这个函数更新一个全局静态mbstate_t类型的对象,因为它处理通过字符串,并不能同时由两个线程调用,wcsrtombs应在这种情况下,使用.
原文:
In most implementations, this function updates a global static object of type mbstate_t as it processes through the string, and cannot be called simultaneously by two threads, wcsrtombs should be used in such cases.
POSIX指定一个常见的扩展:如果
dst
是一个空指针,这个函数返回的字节将被写入到dst
,如果转换。类似的行为标准wcsrtombs原文:
POSIX specifies a common extension: if
dst
is a null pointer, this function returns the number of bytes that would be written to dst
, if converted. Similar behavior is standard for wcsrtombs.[编辑] 参数
dst | - | 窄字符数组的多字节字符将被存储的指针
原文: pointer to narrow character array where the multibyte character will be stored |
src | - | 指针转换成一个空结尾的宽字符串的第一个元素
原文: pointer to the first element of a null-terminated wide string to convert |
len | - | 数所指向的字节数组中的DST
原文: number of byte available in the array pointed to by dst |
[编辑] 返回值
如果成功,则返回的字节数(包括任何移位序列,但不包括终止'\0'),写入的字符数组,该数组的第一个元素是指向
dst
.原文:
On success, returns the number of bytes (including any shift sequences, but excluding the terminating '\0') written to the character array whose first element is pointed to by
dst
.转换错误(如果遇到无效的宽字符),返回(size_t)-1.
原文:
On conversion error (if invalid wide character was encountered), returns (size_t)-1.
[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
宽字符串转换成窄的多字节字符串,给定的状态 原文: converts a wide string to narrow multibyte character string, given state (函数) | |
多字节字符串转换成一个狭窄的宽字符串 原文: converts a narrow multibyte character string to wide string (函数) | |
C++ documentation for wcstombs
|