1

I am trying to save a string to one ini file with UTF-8 format. I want to edit one of the string values but I am unable to.

Can somebody help by providing an example?

 Source: test.ini; DestDir: {app}; 

[INI]
Filename: {app}\test.ini; Section: testclient; Key: PlayerName; String: "{code:GetUserName}";

procedure InitializeWizard();
var
NameEdit: TNewEdit;

function GetUserName(Param: String): string;
begin
result := NameEdit.Text;
end;

procedure InitializeWizard0();

begin

  PlayerSettingsPage := CreateCustomPage(wpSelectComponents, 'Test', '');
  NameEdit := TNewEdit.Create(WizardForm);
  NameEdit.Parent := PlayerSettingsPage.Surface;
  NameEdit.Left := 25;
  NameEdit.Top := NameLabel.Top + 43;
  NameEdit.Width := 130;
  NameEdit.Text :='Enter your Pla';
end;

Its neccesary to save the ini in UTF-8 because the software I am using only accepts an ini file with UTF-8 format.

If the ini am using to be edited, is in ansi format, will not save properly the unicode fonts, will show only this: ?????, and if the ini was in unicode [UTF-16LE] the ini show the unicode characters properly, but when the game load it will not show them.

Then if the ini am using to be edited is in UTF-8 format, the inno setup do not save the text properly in it. Then i saw in the internet that inno setup have a special code to do it but i do not know how to use it good.

SaveStringsToUTF8File

Am using Inno Setup Unicode.

Dielo
  • 603
  • 2
  • 12
  • 25
  • @jachguate UTF-8 is Unicode but Unicode is not only UTF-8. UTF-16, UTF-32 are also Unicode but all of them has to be handled in a different way. Without having BOM you have to know what Unicode Format was used in Textfile – Sir Rufo Dec 06 '12 at 16:15
  • @Sir I know that, If you re-read my comment, you'll see I'm commenting on this statement of the question: _"The software do not accept the ini file in unicode format"_, while at the same time the OP is asking to write it in UTF-8, which happens to be Unicode. – jachguate Dec 06 '12 at 16:36
  • There is a difference in between Save a file with unicode format, and save a file with UTF-8 Format, if you save an ini using notepad you will see a difference in between them, size for example. The software i am talking about is a game, this game only accept the name player from the ini, if the ini was saved in UTF-8 Format. Its easy to save the ini in unicode, but if i do that the game cannot load the player name... because the game only load the ini if was saved in UTF-8 format. I can do this manually but i want the user of my installer to do this from the installer. – Dielo Dec 06 '12 at 22:14
  • I edited my questions about the test.ini and rev.ini thing... the target file is: test.ini, the other thing was a mistake. – Dielo Dec 06 '12 at 22:17
  • Why do you have an [Ini] entry that calls a code function that does not actually return a string to write? In fact none of the code above makes any sense. All you're going to do is to end up clearing the PlayerName. – Miral Dec 08 '12 at 08:51
  • The game only reads an ini with UTF-8 format, dont read ini with unicode[UTF-16LE], and if i use ansi, the game do not load unicode fonts, then.. my solution for now... to have an ini file with unicode[UTF-16LE] to be saved in the game files, and make the installer to run after the setup, an "iconv" script to convert the ini file with unicode[UTF-16LE] to an ini file in UTF-8 format. And its working good. – Dielo Dec 16 '12 at 02:36
  • The question was edited to have more sens, in my last comment i wrote the solution to my problem, but i used another software... inno setup must have a solution to do this from the script, like using this code: `SaveStringsToUTF8File` but i do not know how to usit. – Dielo Dec 16 '12 at 02:56

0 Answers0