我有一个字符串,其中可能包含Unicode字符,我想将其写入Windows上的文件。下面是我发布的一小段示例代码,我的问题在于当我在Windows上打开并读取值时,它们都被解释为UTF-16字符。
如果我在Wordpad等软件中打开文件,字符也会被解释为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);
如果我在Wordpad等软件中打开文件,字符也会被解释为UTF-16编码。我做错了什么吗?