VC ++ 6中具有UTF-8编码的INI文件 [英] INI file with UTF-8 encoding in VC++6

查看:419
本文介绍了VC ++ 6中具有UTF-8编码的INI文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想使用VC ++(VC ++ 6)从创建一个具有UTF-8编码的 INI文件并对其进行读/写数据在 MS visual studio 6 上.请提出一些建议.代码会更有帮助.
请注意,这是在Visual Studio 6中提供的(VS2003和VS2005已经提供了很多帮助,而不能用于此目的).

请帮帮我.

在此先感谢.

Hi,
I want to CREATE an INI file with UTF-8 encoding and read/write data from/to it using VC++(VC++6) on MS visual studio 6.Somebody please suggest how this can be done.Code will be more helpful.
Please note that this is in visual studio 6 (lot of help is already available with VS2003,VS2005 which is not serving the purpose).

please help me.

Thanks in Advance.

推荐答案

如果我们将文件保存在UTF-8中,则必须先添加3个BOM字符,然后再写入要保存在文件中的数据.

例如:
If we save our file in UTF-8 than we must add 3 BOM char first and than write data that we want to save in file.

For Example:
char strUTF8[] = { unsigned char(0xEF), unsigned char(0xBB), unsigned char(0xBF),''\0'' };
CStdioFile m_OutPutFile;
m_OutPutFile.Open(strOPfileName,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
m_OutPutFile.Write(strUTF8,strlen(strUTF8)*sizeof(char));
m_OutPutFile.Close();


您确定您确实需要INI吗?这将花费大量的工作时间,而结果却非常有限.但是,请参阅我对以上问题的评论.

我建议您改用XML. Parser随时可用,UTF-8是事实上的标准,支持许多其他字符集,表达能力实际上是无限的.

—SA
Are you sure you really need INI? It would take good amount of your working time with very limited results. However, see my comment to the question above.

I would suggest you use XML instead. Parser is readily available, and UTF-8 is standard-de-facto, many other charsets are supported, expressive ability is virtually unlimited.

—SA


这篇关于VC ++ 6中具有UTF-8编码的INI文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆