Lena wrote:Sorry, I do not fully understand.
I create VCL project in C++ Builder Berlin.
Then you are using a Unicode-based RTL and GUI. So you should be using Unicode files to avoid any possible data loss during ANSI<->Unicode conversions.
Lena wrote:I create ini files in notepad and save in notepad UTF-8.
Then you need to load it as UTF-8, especially since it contains non-ASCII characters in it. In particular, this line:
- Code: Select all
std::unique_ptr<TIniFile> FileINI(new TIniFile(path));
Needs to be changed to this:
- Code: Select all
std::unique_ptr<TMemIniFile> FileINI(new TMemIniFile(path, TEncoding::UTF8));
Lena wrote:After that I do not see the Russian letters in ListBox1.
On Windows, TIniFile wraps the Win32 PrivateProfile API. On most Windows versions (at least up to Windows 7 - I didn't test Windows 8+), the Unicode version of the PrivateProfile functions do not support UTF-8 files, only UTF-16 files. So ReadSections() returns an empty TStringList, and ReadString() returns the specified default string. If you save your INI file as UTF-16 instead of UTF-8, then TIniFile works correctly.
TMemIniFile does not have that limitation. It can load and save UTF-8 files just fine, as long as you use TEncoding::UTF8. And TIniFile is an alias for TMemIniFile on non-Windows platforms.