I'm trying to open an INI file on Mac OSX using TIniFile
:
SettingsFile := TIniFile.Create(aINIFileName); //Ini vertion
Try
iUpdateMaj := SettingsFile.ReadInteger('CurrentVersion', 'Maj', 0);
iUpdateMin := SettingsFile.ReadInteger('CurrentVersion', 'Min', 0);
iUpdateRel := SettingsFile.ReadInteger('CurrentVersion', 'Rel', 0);
Finally
SettingsFile.Free;
End;
The exact error I got is:
(EEncodingError) No mapping for the Unicode character exists in the target multi-byte code page.
This was working fine before in Yosemite, but since El Capitan it is no longer working.
From research I've done, the problem is related to Unicode endoding. I know that the INI file created with Notepad is encoded in UTF-8, and TIniFile
use TStrings
internally.
Does anyone have an idea how I can resolve this issue?
Your code looks perfectly fine if your .ini file is UTF-8 encoded and contains valid UTF-8 data. I don't know what is inside of your file, but it looks like your .ini file does not contain valid UTF-8 data.
So you'd have to find what encoding your .ini file uses. If your .ini file is ANSI, then you can open it like this:
SettingsFile := TIniFile.Create(aINIFileName, TEncoding.ANSI);