How to read/write Chinese/Japanese characters from/to INI files?

前端 未结 4 1689
陌清茗
陌清茗 2020-12-18 14:13

Using WritePrivateProfileString and GetPrivateProfileString results in ??? instead of the real characters.

4条回答
  •  难免孤独
    2020-12-18 15:10

    The WritePrivateProfileStringW function will write the INI file in legacy system encoding (e.g. Shift-JIS on a Japanese system) because it is a legacy support function. If you want to have a fully Unicode-enabled INI file, you will need to use an external library.

    Try SimpleIni http://code.jellycan.com/simpleini/

    It is C++, single header file, template library with an MIT licence (i.e. commercial use is OK). Include it into your source file and use it. It is cross-platform, supports UTF-8 and legacy encoded files, and can read and write the INI file largely preserving comments and structure, etc. Easiest to check out the page.

    It's been around for a while and is appears to be used by quite a number of people. I wrote it and continue to support it.

提交回复
热议问题