- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个名为 GetServerName
的函数.我需要传递文件名(例如“test.txt”)以及所需的部分字符串(例如“服务器”)test.txt
文件包含这样的东西
data1 | abcd
data2 | efgh
server| 'serverName1'
data3 | ijkl
GetServerName('test.txt', 'server')
的内容。它应该返回
serverName1
.
test.txt
之前是 ANSI 编码的文件。现在它可以是 ANSI 编码的文件或 Unicode 编码的文件。下面的函数对 ANSI 编码的文件正常工作,但如果文件以 UNICODE 编码,则会出现问题。我怀疑
LoadStringsFromFile
功能。因为当我调试时,我可以看到它返回 Unicode 字符而不是人类可读的字符。如何简单地解决我的问题? (或者如何找到我的文件的编码类型以及如何将UNICODE字符串转换为ANSI进行比较,然后我可以自己做)
function GetServerName(const FileName, Section: string): string;
//Get Smartlink server name
var
DirLine: Integer;
LineCount: Integer;
SectionLine: Integer;
Lines: TArrayOfString;
//Lines: String;
AHA: TArrayOfString;
begin
Result := '';
if LoadStringsFromFile(FileName, Lines) then
begin
LineCount := GetArrayLength(Lines);
for SectionLine := 0 to LineCount - 1 do
begin
AHA := StrSplit(Trim(Lines[SectionLine]), '|')
if AHA[0] = Section then
begin
Result := AHA[1];
Exit;
end
end
end;
end;
最佳答案
首先,请注意 Unicode 不是一种编码。 Unicode 是一个字符集。编码为 UTF-8, UTF-16, UTF-32等等。所以我们不知道您实际使用的是哪种编码。
在 Inno Setup 的 Unicode 版本中, LoadStringsFromFile
function默认情况下使用当前的 Windows Ansi 编码。
但是,如果文件有 UTF-8 BOM ,它将相应地处理内容。 BOM 是自动检测 UTF-8(和其他 UTF-*)编码的常用方法。您可以使用 Windows 记事本使用 BOM 创建 UTF-8 编码的文件。
native 不支持 UTF-16 或其他编码。
读取UTF-16文件的实现见Inno Setup Pascal Script - Reading UTF-16 file .
要处理任何编码的文件,包括没有 BOM 的 UTF-8,请参阅 Inno Setup - Convert array of string to Unicode and back to ANSI或 Inno Setup replace a string in a UTF-8 file without BOM .
关于unicode - Inno Setup 读取 Ansi 和 Unicode 编码的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38968230/
我需要编辑或替换 About Setup 中的文本Inno Setup 的对话框文本。 这是一张图片: 在互联网上查看我得到了这个代码: [Files] Source: CallbackCtrl.dl
我最近发现一些旧的 PC 游戏可以在我的 Windows 10 64 位计算机上玩。我查看了各种在线资源以使游戏正常运行。现在我有兴趣为使游戏正常运行所采取的所有各种步骤创建一个自定义安装程序。我成功
是否可以获得用于 Inno Setup 安装程序的 Inno Setup 版本号? 我找不到记录的开关来返回其版本号(例如 5.5.6),而且似乎没有暴露给 Inno Setup 脚本的预定义版本常量
如何更改 setup-*.bin(Inno Setup 内部压缩存档文件)的名称、扩展名和位置 默认存档位置:{src} 我要的位置:{src}\Data(Data是一个文件夹。) 最佳答案 有很多方
这是用于 Inno Setup 的 [Setup] 部分中的 LicenseFile 属性的标准 RTF 文档: 是否可以向此页面添加打印按钮以触发打印许可协议(protocol)? 我看到了一个类似
我有一个 Inno Setup 脚本可以将我的应用程序变成一个 exe。 当我使用 Inno Setup 版本 6 编译代码时,输出文件大小为 110MB(如 Windows Explorer 大
编译了 Inno Setup 脚本 (IS v5.4.2),但是当运行生成的 Setup.exe 时,出现了一个错误对话框,内容如下: 内部错误:ExtractTemporaryFile:找不到文件“
Inno Setup - 我想创建一个类似于屏幕截图的安装程序。 安装程序应在左侧突出显示当前步骤。 如何实现? 最佳答案 @Bill_Stewart 是正确的,普通的 Inno Setup 不提供如
图像作为安装程序背景。如何使用 inno 5.5.9 做到这一点? 最佳答案 我认为这在 Inno Setup 中是不可能的。也许是一些 Inno Setup 克隆。 问题是Inno Setup中的所
这个问题在这里已经有了答案: Inno Setup - Signing fails with "Sign Tool failed with exit code 0x1" (2 个答案) 关闭 3 年
如何获取有关安装程序中包含的文件的信息(最后修改时间戳、文件大小)?通过使用文件的路径,很容易引用磁盘上的文件。但是当文件没有路径时,如何在安装程序中引用它呢? 当安装程序初始化时,我想检查磁盘上是否
Inno Setup 中的单词补全是如何工作的? 如果我在代码中的任何标识符或单词的中间或末尾按 Alt+Right,则没有任何反应。 我找不到任何要安装的扩展,也找不到该主题的 Internet 答
从这里开始:Inno Setup Placing image/control on custom page . 这是做我需要的: CustomPage := CreateCustomPage(wpLi
我的安装程序在组件页面中有一个可视错误。在您开始向下滚动页面之前看起来还不错,但开始看起来一团糟。 我认为问题出在代码中的某个地方,但仅在绝对干净的脚本上重新创建了组件部分,问题仍然存在。尝试更改缩放
如何在 Inno Setup 编译器中为我们的设置提供背景全屏图像。 喜欢下面这张图。 最佳答案 不要那样做。这违反了 Windows 设计指南。 无论如何,如果必须,请使用 WindowVisibl
如何在代码中使用 [Setup] 部分的值? 我怀疑我没有正确使用该工具;也许我应该以完全不同的方式来做这件事。 [Setup] MyValue=some value [code] function
如何自定义 Inno Setup 安装程序的欢迎页面? 我想创建一个类似于 Skype 安装程序的安装程序,只有 3 个页面: 带有一些选项的自定义欢迎页面 进度页 使用“运行程序”选项完成页面 但是
我已经为我想更新的程序创建了文件。 我希望在安装之前,检查程序是否也在标准目录中,如果不是,则正确的目录可以选择程序所在的位置。 我试过这个: [Files] Source: "C:\Data"; D
我想在您选择安装位置的页面之后创建一个自定义向导页面。 我已经在 InitializeWizard 中看到了如何创建自定义页面并将它们添加到向导中。程序。 我的问题是,当我创建自定义页面时,安装位置选
我已经安装了我的程序。但是如果我尝试再次安装它,它会安装并且程序被替换。 我看到这个问题 Inno Setup - How to display notifying message while ins
我是一名优秀的程序员,十分优秀!