如何在INI文件中读取/写入中文/日语字符? [英] How to read/write Chinese/Japanese characters from/to INI files?
问题描述
使用WritePrivateProfileString
和GetPrivateProfileString
会导致???
而不是真实字符.
Using WritePrivateProfileString
and GetPrivateProfileString
results in ???
instead of the real characters.
推荐答案
GetPrivateProfileString()
和WritePrivateProfileString()
可以使用Unicode.
GetPrivateProfileString()
and WritePrivateProfileString()
will work with Unicode, sort of.
如果ini文件是UTF-16LE编码的,即它具有UTF-16 BOM,则这些功能将以Unicode工作.但是,如果函数必须创建文件,则它们将创建一个ANSI文件,并且只能在ANSI中工作.
If the ini file is UTF-16LE encoded, i.e. it has a UTF-16 BOM, then the functions will work in Unicode. However if the functions have to create the file they will create an ANSI file and only work in ANSI.
因此,要将函数与Unicode一起使用,请在首次使用它之前创建您的ini文件,并在其上写入UTF-16LE字节顺序标记.然后照常进行.
So to use the functions with Unicode, create your ini file before you first use it and write a UTF-16LE Byte Order Mark to it. Then carry on as normal.
请注意,函数不能与UTF-8一起使用..
请参阅 Michael Kaplan的博客,以获取比您想要的更多的详细信息知道这一点.
See Michael Kaplan's blog for more detail than you ever wanted to know about this.
这篇关于如何在INI文件中读取/写入中文/日语字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!