Could there be encoding-related problems when storing unicode strings in ini files?

后端 未结 2 866
我寻月下人不归
我寻月下人不归 2021-01-25 16:58

There are already questions regarding unicode and ini files, but many of them are rather domain-specific. So I am not sure if the answer can be applied to the general case.

2条回答
  •  迷失自我
    2021-01-25 17:52

    The answer is: Yes, there can be problems depending on whether the file already exists and (if it exists) how its content is encoded.

    An ini file is treated as Unicode if its content is already Unicode. Internally this seems to be determined by the IsTextUnicode function. And for this function the right BOM in the file serves as a big hint towards Unicode. So just by using WritePrivateProfileStringW you cannot ensure to write Unicode to the ini file, instead you have to prepare the file.

    Source: Michael Kaplan's Blog

提交回复
热议问题