- 论坛徽章:
- 0
|
- #include <iostream>
- #include <locale>
- #include <unicode/regex.h>
- using namespace std;
- using namespace icu;
- int main() {
- const int MAX_SIZE = 255;
- locale loc("");
- wcout.imbue(loc);
-
- puts("输入文字");
- fgets(str, MAX_SIZE, stdin);
- str[strlen(str) - 1] = '\0';
- UnicodeString input(str, "gb2312");
- wcout<<"input:"<<input.getTerminatedBuffer()<<'\n';
- return 0;
- }
复制代码 请问
使用icu库。构筑的UnicodeString构造,里面存的输入的文字,是gb2312编码?还是unicode编码?
下面是相关文档的。
我对UnicodeString不理解,他和char[],w_char[],UChar [],string都什么关系?请指点,谢谢!
###########################################
UnicodeString::UnicodeString ( const char * codepageData,
const char * codepage = 0
)
char* constructor.
Parameters:
codepageData an array of bytes, null-terminated
codepage the encoding of codepageData. The special value 0 for codepage indicates that the text is in the platform's default codepage.
If codepage is an empty string (""), then a simple conversion is performed on the codepage-invariant subset ("invariant characters") of the platform encoding. See utypes.h. Recommendation: For invariant-character strings use the constructor UnicodeString(const char *src, int32_t length, enum EInvariant inv) because it avoids object code dependencies of UnicodeString on the conversion code.
Stable:
ICU 2.0 |
|