ofstream fo("log");
11 ucs_char_t ucs_buf[10];
12 ucs_buf[0] = 0x61;
13 ucs_buf[1] = 0x62;
14 ucs_buf[2] = 0x65;
15 ucs_buf[3] = 0xa0;
16 ucs_buf[4] = 0x4d;
17 ucs_buf[5] = 0x58;
18 ucs_buf[6] = 0xa0;
19 ucs_buf[7] = 0x6211;
20 ucs_buf[8] = 0;
21 char char_buf[20];
22 ucs_uc_to_utf8_buf(char_buf, ucs_buf,20);
23 string str(char_buf);
24 cout << str <<endl;
25 fo << str << endl;
26 stringstream ss;
27 ss << str;
28 string tok;
29 cout << "stringstream\n";
30
31 fo << "stringstream\n";
32 while (ss >> tok) {
33 cout << tok <<endl;
34 fo << tok <<endl;
35 }
36 fo.close();
需要将普通空格(0x20)替换为特殊空格(0xa0),但是stringstream也不会处理这个特殊空格
output:
abe MX 我
stringstream
abe MX 我