【问题标题】:UTF-8 characters not displaying correctly in Inno SetupUTF-8 字符在 Inno Setup 中无法正确显示
【发布时间】:2022-01-25 23:39:48
【问题描述】:

我已经看到了一些关于此的其他线程,但我花了一段时间试图对其进行排序但无济于事。

这是我的 .iss 文件的通用版本:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define AppName "MyApp"
#define CompanyName "MyCompany"
#define FileName "File Name"
#define AppExeName "App Exe.exe"
#define AppIcon "..\icon.ico"
#define AppId "app.id"
#define AppURL "mywebsite"
#define AppSrcDir "path\to\app\directory"
#define AppTargetDir "{userappdata}\" + CompanyName + "\" + AppName
#define AppVersion GetFileVersion(AppSrcDir + "\" + AppExeName)
#define AppPublisher "Publisher"
#define LaunchMessage "Launch Message"
#define AppProtocol "protocol"
#define OutputDir "path\to\output"
#define SetupFilename FileName + "-setup-" + AppVersion
#define SetupImage "..\setup.bmp"
#define InstallerMessage "Some message with a German character - ö"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)

AllowCancelDuringInstall=no
AppId={#AppId}
AppName={#AppName}
AppVersion={#AppVersion}
AppVerName={#AppName} {#AppVersion}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}
AppUpdatesURL={#AppURL}
DefaultDirName={#AppTargetDir}
DefaultGroupName={#CompanyName}
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes
DisableReadyMemo=yes
OutputDir={#OutputDir}
OutputBaseFilename={#SetupFilename}
PrivilegesRequired=lowest
SetupIconFile={#AppIcon}
SignTool=signtool
Compression=lzma/ultra64
SolidCompression=yes
WizardSmallImageFile={#SetupImage}
UninstallDisplayIcon={app}\{#AppExeName}

[InstallDelete]
Type: filesandordirs; Name: {#AppTargetDir}

[Languages]
Name: de; MessagesFile: "compiler:Languages\German.isl"

[Files]
Source: "{#AppSrcDir}\*"; DestDir: "{app}"; Flags: recursesubdirs
Source: "path\to\other\installers\win32\*"; DestDir: "{app}\redist";
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}"; WorkingDir: "{app}";
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; WorkingDir: "{app}";

[Run]
FileName: "{app}\redist\installer.exe"; Parameters: "/S /v/qn"; WorkingDir: "{app}"; StatusMsg: "{#InstallerMessage}";

我遇到的问题是它没有正确显示InstallerMessage 文本。 ö 字符无法正确呈现。

我正在使用 Unicode 版本的 Inno Setup(带有“(u)”)。

我看到一些提到使用字节顺序标记,但我没有看到任何示例。我尝试使用 UTF-8 编码器转换整个字符串,并在开始时添加字节顺序标记,但它不起作用。我完全被难住了!

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    确保您的 .iss 文件使用 UTF-8 编码和 BOM

    当然,您需要 Inno Setup 的 Unicode 版本(Inno Setup 6 的唯一版本)。


    Pascal 脚本代码中是否也使用了该字符串(不是什么,只是为了其他人的利益而提及它,谁可能会发现这个问题),您还必须使用Inno Setup 5.6.0 或更高版本。早期版本不支持 Pascal Script 中的 UTF-8。

    Pascal 脚本更改:
    Unicode Inno 设置:输入源现在支持 Unicode。例如,以前必须写S := #$0100 + #$0101 + 'Aa';,现在可以直接写S := 'ĀāAa';。另请参阅新的 UnicodeExample1.iss 示例脚本。

    【讨论】:

    • 是的,这同样适用于 iss 可能导入的许可证文件。此文件还需要带有 BOM 的 UTF-8 才能正确呈现非 ASCII 字符。非常感谢@Reverate 提供了如何使用 VSCode 快速转换它的提示。
    猜你喜欢
    • 2011-08-09
    • 2013-04-12
    • 1970-01-01
    • 2020-04-22
    • 2020-05-15
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    相关资源
    最近更新 更多