【发布时间】:2011-04-27 18:41:16
【问题描述】:
我有一个字符串,其中可能包含或不包含 unicode 字符,我正在尝试将其写入 Windows 上的文件。下面我发布了一段代码示例,我的问题是当我打开并从窗口读取值时,它们都被解释为 UTF-16 字符。
char* x = "Fool";
FILE* outFile = fopen( "Serialize.pef", "w+,ccs=UTF-8");
fwrite(x,strlen(x),1,outFile);
fclose(outFile);
char buffer[12];
buffer[11]=NULL;
outFile = fopen( "Serialize.pef", "r,ccs=UTF-8");
fread(buffer,1,12,outFile);
fclose(outFile);
如果我在写字板等中打开文件,这些字符也会被解释为 UTF-16。我做错了什么?
【问题讨论】:
标签: c++ windows unicode file-io utf-8