Browse Source

Unicode Inno Setup: Unicode is now supported for the input source. Added UnicodeExample1.iss.

Martijn Laan 7 years ago
parent
commit
c3a102f5bb
5 changed files with 46 additions and 6 deletions
  1. 29 0
      Examples/UnicodeExample1.iss
  2. 0 1
      ISHelp/isetup.xml
  3. 8 4
      Projects/ScriptCompiler.pas
  4. 4 0
      setup.iss
  5. 5 1
      whatsnew.htm

+ 29 - 0
Examples/UnicodeExample1.iss

@@ -0,0 +1,29 @@
+; -- UnicodeExample1.iss --
+; Demonstrates some Unicode functionality. Requires Unicode Inno Setup.
+;
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!
+
+[Setup]
+AppName=ɯɐɹƃoɹd ʎɯ
+AppVerName=ɯɐɹƃoɹd ʎɯ version 1.5
+DefaultDirName={pf}\ɯɐɹƃoɹd ʎɯ
+DefaultGroupName=ɯɐɹƃoɹd ʎɯ
+UninstallDisplayIcon={app}\ƃoɹdʎɯ.exe
+Compression=lzma2
+SolidCompression=yes
+OutputDir=userdocs:Inno Setup Examples Output
+
+[Files]
+Source: "MyProg.exe"; DestDir: "{app}"; DestName: "ƃoɹdʎɯ.exe"
+Source: "MyProg.chm"; DestDir: "{app}"; DestName: "ƃoɹdʎɯ.chm"
+Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
+
+[Icons]
+Name: "{group}\ɯɐɹƃoɹd ʎɯ"; Filename: "{app}\ƃoɹdʎɯ.exe"
+
+[Code]
+function InitializeSetup: Boolean;
+begin
+  MsgBox('ɯɐɹƃoɹd ʎɯ', mbInformation, MB_OK);
+  Result := True;
+end;

+ 0 - 1
ISHelp/isetup.xml

@@ -2664,7 +2664,6 @@ Type: files; Name: "{win}\MYPROG.INI"
     <ul>
     <li>The Unicode compiler sees type 'String' as a Unicode string, and 'Char' as a Unicode character. Its 'AnsiString' type hasn't changed and still is an ANSI string. Its 'PChar' type has been renamed to 'PAnsiChar'.</li>
     <li>The Unicode compiler is more strict about correct ';' usage: it no longer accepts certain missing ';' characters.</li>
-    <li>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 <tt>S := #$0100 + #$0101 + 'Aa';</tt>), or load the string from a file using <tt>LoadStringsFromFile</tt>, or use a <tt>{cm:...}</tt> constant.</li>
     <li>Some support functions had their prototype changed: some parameters of <tt>CreateOutputMsgMemoPage</tt>, <tt>RegQueryBinaryValue</tt>, <tt>RegWriteBinaryValue</tt>, <tt>OemToCharBuff</tt>, <tt>CharToOemBuff</tt>, <tt>LoadStringFromfile</tt>, <tt>SaveStringToFile</tt>, and <tt>GetMD5OfString</tt> are of type AnsiString now instead of String.</li>
     <li>Added new <tt>SaveStringsToUTF8File</tt>, and <tt>GetMD5OfUnicodeString</tt> support functions.</li>
     <li>Added new 'Int64' type, supported by <tt>IntToStr</tt>. Also added new <tt>StrToInt64</tt>, <tt>StrToInt64Def</tt>, and <tt>GetSpaceOnDisk64</tt> support functions.</li>

+ 8 - 4
Projects/ScriptCompiler.pas

@@ -268,8 +268,8 @@ begin
   end;
 
 {$IFDEF UNICODE}
-  { Convert Position from an ANSI string index to a UTF-16 string index }
-  Position := Length(String(Copy(FScriptText, LineStartPosition, Position - 1))) + 1;
+  { Convert Position from the UTF8 encoded ANSI string index to a UTF-16 string index }
+  Position := Length(UTF8ToString(Copy(FScriptText, LineStartPosition, Position - 1))) + 1;
 {$ENDIF}
   Col := Position;
 end;
@@ -343,8 +343,11 @@ var
 begin
   Result := False;
 
-  { Note: Cast disabled on non-Unicode to work around D2 codegen bug }
-  FScriptText := {$IFDEF UNICODE}AnsiString{$ENDIF}(ScriptText);
+{$IFDEF UNICODE}
+  FScriptText := UTF8Encode(ScriptText);
+{$ELSE}
+  FScriptText := ScriptText;
+{$ENDIF}
 
   PSPascalCompiler := TPSPascalCompiler.Create();
 
@@ -355,6 +358,7 @@ begin
     PSPascalCompiler.BooleanShortCircuit := True;
 {$IFDEF UNICODE}
     PSPascalCompiler.AllowDuplicateRegister := False;
+    PSPascalCompiler.UTF8Decode := True;
 {$ENDIF}
 
     PSPascalCompiler.OnUses := PSPascalCompilerOnUses;

+ 4 - 0
setup.iss

@@ -74,6 +74,7 @@ Name: fileassoc; Description: "{cm:AssocFileExtension,Inno Setup,.iss}"
 ; Remove Unicode-only files if needed
 #ifndef UNICODE
 Type: files; Name: "{app}\Languages\*.islu"
+Type: files; Name: "{app}\Examples\UnicodeExample1.iss"
 #endif
 ; Remove ISPP files if needed (leave ISPP.chm)
 Type: files; Name: "{app}\ISPP.dll"; Check: not ISPPCheck
@@ -143,6 +144,9 @@ Source: "Examples\CodeDll.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion
 Source: "Examples\CodeAutomation.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\CodeAutomation2.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\CodePrepareToInstall.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
+#ifdef UNICODE
+Source: "Examples\UnicodeExample1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
+#endif
 Source: "Examples\UninstallCodeExample1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch
 Source: "Examples\MyDll.dll"; DestDir: "{app}\Examples"; Flags: ignoreversion signonce touch
 Source: "Examples\MyDll\C\MyDll.c"; DestDir: "{app}\Examples\MyDll\C"; Flags: ignoreversion touch

+ 5 - 1
whatsnew.htm

@@ -35,7 +35,11 @@ For conditions of distribution and use, see <a href="http://www.jrsoftware.org/f
 <li>Added new [Setup] section directive: <tt>SignToolRetryDelay</tt>, which defaults to 500. Specifies the number of milliseconds the Setup Compiler should wait before any automatic digital signing retries specified by <tt>SignToolRetryCount</tt>.</li>
 <li>Added new [Setup] section directive: <tt>SignToolMinimumTimeBetween</tt>, which defaults to 0. If not set to 0, specifies the minimum number of milliseconds that should have elapsed between consecutive digital signing actions by the Setup Compiler. For example, if set to 5000 then the Setup Compiler will perform 1 digital signing per 5 seconds at most. Can be used to avoid being rejected by rate limiting timestamp services.</li>
 <li>Added new [Setup] section directive <tt>ArchitecturesAllowed</tt> value: <tt>arm64</tt>. This can be used to not allow Setup to run on Windows 10 on ARM64. Note that Windows 10 on ARM64 only supports 32-bit (x86) binaries and therefore Setup (even in older 3s) will never install in 64-bit mode on Windows 10 on ARM64.</li>
-<li>Pascal Scripting: Added new <tt>IsX86</tt>, <tt>IsX64</tt>, <tt>IsIA64</tt>, and <tt>IsARM64</tt> support functions.</li>
+<li>Pascal Scripting changes:
+<ul>
+  <li>Unicode Inno Setup: Unicode is now supported for the input source. For example, where before you had to write <tt>S := #$0100 + #$0101 + 'Aa';</tt> you can now write <tt>S := '&#x0100;&#x0101;Aa';</tt> directly. Also see the new <i>UnicodeExample1.iss</i> example script. Based on a contribution by <a href="https://github.com/ElSanchez666" target="_blank">ElSanchez</a> via <a href="https://github.com/jrsoftware" target="_blank">GitHub</a>.</li>
+  <li>Added new <tt>IsX86</tt>, <tt>IsX64</tt>, <tt>IsIA64</tt>, and <tt>IsARM64</tt> support functions.</li>
+</ul>
 <li>Any [Files] entries with the <tt>deleteafterinstall</tt> flag or with <tt>DestDir</tt> set to <tt>{tmp}</tt> or a subdirectory of <tt>{tmp}</tt> are no longer included in the <tt>EstimatedSize</tt> value in the Uninstall registry key.</li>
 <li><i>Fix:</i> In 5.5.9 it was no longer possible to include a drive colon in [Setup] section directive <tt>OutputManifestFile</tt>.</li>
 <li>Unicode [Code] based on RemObjects Pascal Script Git commit 4b310a0fe3905b8b1b6004a2891a8388a3fb3c1c.</li>