std::wcsxfrm
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <cwchar> 中定义
|
||
std::size_t strxfrm( const wchar_t* dest, const wchar_t* src, std::size_t count ); |
||
。 null结尾的宽指向的字符串变换
src
为实现定义的形式,比较两种转化的字符串std::wcscmp给出了相同的结果,在当前的C语言环境比较原始的字符串std::wcscoll.原文:
Transforms the null-terminated wide string pointed to by
src
into the implementation-defined form such that comparing two transformed strings with std::wcscmp gives the same result as comparing the original strings with std::wcscoll, in the current C locale.。
count
的第一个字符的转换后的字符串被写入到目的地,包括终止空字符,返回的全面转化的字符串的长度,不包括终止空字符.原文:
The first
count
characters of the transformed string are written to destination, including the terminating null character, and the length of the full transformed string is returned, excluding the terminating null character.。
count
是0,然后dest
是一个空指针.原文:
If
count
is 0, then dest
is allowed to be a null pointer.目录 |
[编辑] 。注释。
。正确的缓冲区,可以接收整个转化的字符串的长度是1+std::wcsxfrm(NULL, src, 0)。
原文:
The correct length of the buffer that can receive the entire transformed string is 1+std::wcsxfrm(NULL, src, 0)
[编辑] 。参数。
dest | - | 。广泛null结尾的字符串写入转换后的字符串的第一个元素的指针。
原文: pointer to the first element of a wide null-terminated string to write the transformed string to |
src | - | 。指针null结尾的宽字符的字符串转换。
原文: pointer to the null-terminated wide character string to transform |
count | - | 。最大字符数输出。
原文: maximum number of characters to output |
===。 返回值。===
。转化的宽字符串的长度,不包括终止空字符.
原文:
The length of the transformed wide string, not including the terminating null-character.
[编辑] 。为例。
#include <iostream> #include <cwchar> int main() { std::setlocale(LC_ALL, "sv_SE.utf8"); std::wstring in1 = L"\u00e5r"; std::wstring out1(1+std::wcsxfrm(nullptr, in1.c_str(), 0), L' '); std::wstring in2 = L"\u00e4ngel"; std::wstring out2(1+std::wcsxfrm(nullptr, in2.c_str(), 0), L' '); std::wcsxfrm(&out1[0], in1.c_str(), out1.size()); std::wcsxfrm(&out2[0], in2.c_str(), out2.size()); std::wcout << "In the Swedish locale: "; if(out1 < out2) std::wcout << in1 << " before " << in2 << '\n'; else std::wcout << in2 << " before " << in1 << '\n'; std::wcout << "In lexicographical comparison: "; if(in1 < in2) std::wcout << in1 << " before " << in2 << '\n'; else std::wcout << in2 << " before " << in1 << '\n'; }
输出:
In the Swedish locale: år before ängel In lexicographical comparison: ängel before år
[编辑] 。另请参阅。
转换为字符串,这样的strcmp会产生相同的结果strcoll 原文: transform a string so that strcmp would produce the same result as strcoll (函数) | |
[虚]</div></div>
|
转换的字符串排序规则,以便通过比较可以被替换 原文: transforms a string so that collation can be replaced by comparison (虚拟保护成员函数of std::collate )
|
比较两个宽字符串,按照目前的语言环境 原文: compares two wide strings in accordance to the current locale (函数) | |
C documentation for wcsxfrm
|