LoadStringFromFile and StringChangeEx from Unicode Inno Setup (Ansi file)

风格不统一 提交于 2019-11-30 17:37:25
TLama

Since parameters of LoadStringFromFile as well as of StringChangeEx functions are declared, they expect the exact type to be passed, so there's not much to do with it. You will need just to declare another variable just for your StringChangeEx function call and typecast between ANSI & Unicode string types:

var
  UnicodeStr: string;
  ANSIStr: AnsiString;
begin
  if LoadStringFromFile('C:\File.txt', ANSIStr) then
  begin
    UnicodeStr := String(ANSIStr);
    if StringChangeEx(UnicodeStr, 'FromStr', 'ToStr', True) > 0 then
      SaveStringToFile('C:\File.txt', AnsiString(UnicodeStr), False);
  end;
end;

Annoying, isn't it ?

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