LoadStringFromFile and StringChangeEx from Unicode Inno Setup (Ansi file)

前端 未结 1 1193
感情败类
感情败类 2021-01-01 20:31

I\'m trying to update one of my scripts to use the Unicode version of Inno Setup. Unfortunately I\'m running into a problem where StringChangeEx is expecting to see a unicod

相关标签:
1条回答
  • 2021-01-01 21:03

    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 ?

    0 讨论(0)
提交回复
热议问题