Inno Setup Unicode version still doesn't display Cyrillic properly

非 Y 不嫁゛ 提交于 2020-01-05 05:19:26

问题


I am using Inno Setup 5.5.2 (u) and all symbols are fine except the dynamically filled strings in TStringList. I initialize the list and add items this way:

Regions := TStringList.Create;
Regions.Add('Аврен');
Regions.Add('Айтос');
Regions.Add('Аксаково');
Regions.Add('Алфатар');
...

but them I get:

Thanks for looking into this.


回答1:


You can't use Unicode constants in Inno Setup at this time. In documentation there's a quote about it (emphasized by me):

The new RemObjects PascalScript version used by the Unicode compiler supports Unicode, but not for its input source. This means it does use Unicode string types as said, but any literal Unicode characters in the script will be converted to ANSI.

This doesn't mean you can't display Unicode strings: you can for example instead use encoded Unicode characters to build Unicode strings (like S := #$0100 + #$0101 + 'Aa';), or load the string from a file using LoadStringsFromFile, or use a {cm:...} constant.

So from what is written there, you can either encode those constant chars in the following format:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
procedure InitializeWizard;
var
  Regions: TStringList;
  ComboBox: TComboBox;
  CustomPage: TWizardPage;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
  ComboBox := TComboBox.Create(WizardForm);
  ComboBox.Parent := CustomPage.Surface;

  Regions := TStringList.Create;
  try
    Regions.Add(#$0410 + #$0432 + #$0440 + #$0435 + #$043D
    Regions.Add(#$0410 + #$0439 + #$0442 + #$043E + #$0441
    Regions.Add(#$0410 + #$043A + #$0441 + #$0430 + #$043A + #$043E + #$0432 + #$043E
    Regions.Add(#$0410 + #$043B + #$0444 + #$0430 + #$0442 + #$0430 + #$0440
    ComboBox.Items.AddStrings(Regions);
  finally
    Regions.Free;
  end;
end;

Or you can load a list of regions by the suggested LoadStringsFromFile function from an external file and with the output array fill the string list (or directly the combo box).

Or you can make an external custom messages file.



来源:https://stackoverflow.com/questions/18309711/inno-setup-unicode-version-still-doesnt-display-cyrillic-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!