tags:

views:

669

answers:

3

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

A: 

It might just be a problem with how you are displaying or handling the strings. For example, the normal console window can't display japanese strings with printf.

Can you post some of your code?

moogs
+1  A: 

According to the WritePrivateProfileString documentation, there is a Unicode version: WritePrivateProfileStringW. Use that, and you should be able to use Unicode characters.

Chris Jester-Young
A: 

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.

brofield