我正在构建一个需要在英文文件中间添加阿拉伯字符的应用程序,我构建的函数如下:
int main(void) {
std::ifstream mySource("Test2.txt", std::ios::out);
std::filebuf* pbuf = mySource.rdbuf();
std::size_t size = pbuf->pubseekoff(0, mySource.end, mySource.in);
pbuf->pubseekpos(0, mySource.in);
char* buffer = new char[size];
pbuf->sgetn(buffer, size);
mySource.close();
wchar_t* wbuffer = new wchar_t[size];
wbuffer = GetWC(buffer);
setlocale(LC_ALL, "en_GB.utf8");
wbuffer[79] = {0x0041};
std::wofstream outdata2;
outdata2.open("Test6.xml"); // opens the file
outdata2 << wbuffer;
outdata2.close();
return 0;
}
对于如下文本文件:
$ cat dat/rbgtst.txt
400,280: (234,163,097) #EAA361
400,300: (000,000,000) #000000
400,320: (064,101,160) #4065A0
400,340: (220,194,110) #DCC26E
并期待收到
$ cat dat/rbgtst.txt
400,280: (234,163,097) #EAA361
400,300: (000,000,000) #A00000
400,320: (064,101,160) #4065A0
400,340: (220,194,110) #DCC26E
虽然当我把阿拉伯字母ASCII像:
...
wbuffer[79] = {0x0628};
...
我收到以下信息:
$ cat dat/rbgtst.txt
400,280: (234,163,097) #EAA361
400,300: (000,000,000) #
不知道为什么?!