11-14-2025 09:10 AM
I'm using CVI 2020 on Win11. Now I want to save chinese strings into my ini file with Ini_PutString(). Inside the running program, the chinese font is showing fine, but after calling the function Ini_WriteToFile(), the chinese font inside the ini file is = ?. Is utf-8 not supported by the INI Library?
11-17-2025 03:25 AM
Hello,
you’ve run into a limitation of CVI’s INI library. The functions Ini_PutString() and Ini_WriteToFile() in CVI 2020 store strings in ANSI encoding, not UTF-8. This is why non-ASCII characters like Chinese appear as ? in the file. Inside your running program, CVI uses Unicode internally for strings, so the Chinese characters display correctly in the GUI. However, when writing to the INI, the library converts the Unicode string to ANSI, causing any characters outside the current code page to be lost. To handle Chinese characters, you’ll need to bypass the CVI INI functions and write the INI file manually in UTF-8 or UTF-16, for example by opening the file in binary mode, optionally writing a UTF-8 BOM, and writing your strings in UTF-8 encoding. e-zpassma
11-17-2025 04:29 AM - edited 11-17-2025 05:19 AM
Thanks for your answer. Its funny, that the function name in inifile.c is "Ini_WriteToFileUtf8(IniText theIniText, const char pathName[])", very confusing 😄
UPDATE:
Solution: Ini_SetEncoding(g_myInifile, IniFileEncoding_UTF8BOM);