Are there any disadvantages of the Inno Setup Unicode version compared to the Ansi version?
Or what is the reason that still both versions are offered in parallel and not only the Unicode one is left?
Are there any potentials problems, when using the Unicode version for my existing Inno Setup project developed with the Ansi version?
There are no real disadvantages. There are mostly advantages. Obviously the fact that the Unicode version is not limited to legacy Ansi character set. See below for details.
If you are starting new Inno Setup project, always use the Unicode version. There is no reason to use the Ansi version for new projects.
The reason, why is Ansi version of Inno Setup still available, is that the Pascal Script code of Ansi and Unicode versions are not 100% compatible. Mostly they are, but there are differences.
So if your existing installer script does not have any Pascal Script code (there's no
[Code]
section in your.iss
), you can (and should) upgrade to the Unicode version straight away.If you have some Pascal Script code, you should be more careful. See below for details.
Why you want to use Unicode version
For example of problems with the Ansi version, if you run Japanese-only installer built with Ansi version of Inno Setup on English system, you will get:
See also Inno Setup installator has wrong text encoding.
For the same reason, the Ansi version will not be able to create files with names containing characters, that are not present in the legacy Ansi character set of the target machine.
The Unicode version does not have these problems, as documented in the Unicode Inno Setup article:
Additionally there are some small improvements in the Unicode version Pascal Script. They are documented in the Unicode Inno Setup article. On top of that, there are few undocumented improvements:
Inc
/Dec
functions/statements. See Inc function Inno Setup.Variant
support. For example, see Inno Setup: Iterate through array of type Variant (from OleObject) or Is there a way to read the system's information in Inno Setup.case
statement: "colon (':') expected" compiler error on character range in case statement in Inno Setup Pascal script.in
operator with a constant set: It seems that in Ansi version, you always get "Type mismatch" error, unless you store theset
into aset of
variable first.Note, that while the Unicode version does support the
in
operator with a constant set, it does not support ranges in the set expression, soX in [1, 2, 3]
is possible, butX in [1..3]
is not possible, you will get "Closing square bracket (']') expected."TLabel
has transparent background in the Unicode version. See Inno Setup - Transparency under text in page name and description labelsPossible problems in Pascal Script code
There are few areas, where problems can emerge in the Pascal Script code:
Any calls to DLL functions that take string parameters -
string
andPChar
types.AnsiString
should be ok, as it's the same in the Unicode version.In Unicode version,
PChar
was renamed toPAnsiChar
.If you invoke any Windows API function that uses strings, you should switch to its Wide version. E.g. use
GetFileAttributesW
, instead ofGetFileAttributesA
. There's noPWideChar
type. So if your declaration usedPChar
type in Ansi version, and you switch to Wide version of the function, you have to usestring
type instead. Inno Setup will automatically marshal it to theLPCTSTR
(or similar), aka thePWideChar
.The declaration below is correct in Ansi version, but wrong in Unicode version, as the
GetFileAttributesA
takesPAnsiChar
, but thestring
marshals toPWideChar
in the Unicode version.For a full example and solution, see Inno Setup FileExists unable to find existing file.
In rare cases, that you are calling a function that has an out
PWideChar
parameter (var S: PWideChar
), it's very tricky to use it, without the actualPWideChar
type, as in this case you cannot use thestring
marshaling. But it's doable, see Constant for AppData\LocalLow?Similarly to Windows API, some 3rd party libraries also provide a separate Unicode version with Unicode strings in its API. For example ISSkin has
ISSkinU.dll
. See Getting ISSkin to work with latest Inno Setup 5.5.9 Unicode.Any code that uses
string
type as byte array (as in Unicode version, thestring
is wide char (2-byte) array). That's mostly concern, only if your code usesTStream
class methods like:These methods should have really been re-declared with
AnsiString
. Looks like a bug to me.To make these methods usable in Unicode version, use
BufferToAnsi
function by @TLama that is used in many existing answers, like:Unicode version does not allow
set of char
variable (asset
is not allowed for multi-byte types). Though interestingly it supportsset of char
constants in expressions. See "Type mismatch" error on "set of char" in Pascal Script of the Inno Setup Unicode version.FloatToStr
uses a locale specific decimal separator in Ansi version, while always a dot in Unicode version.Unicode version is more strict about use of semicolons. The Ansi version tolerates some missing semicolons, so it can compile even code that is not 100% syntactically correct in this respect.
If your code does not use any of the above, and you have your semicolons right, you should not have any problems with the Unicode version.
After the clear answer here that there is not a real reason to stay with the Ansi Inno Setup version, we switched the beta setup of our product to the Unicode version yesterday and did not see any problems in our own tests.
But one of our beta tester reported now today that this version crashes while creating a firewall exception with following code:
If this code is executed the setup crashes with
in the Windows event log. I asked the beta tester to run the setup with "/LOG" parameter and there is no error shown there at all. Just the complete setup crashes.
To be sure it was the change from Ansi to Unicode causing this problem, we send the beta tester another identical build, just compiled with the Ansi version and no crash there.
So there seems to be some more (negative) side effects of the Unicode version.
We could not reproduce this issue ourselves, just one of our beta testers using this setup: https://www.fs-flightcontrol.com/download/FS-FlightControl-Beta-InnoUnicode.exe Just keep the firewall exception checked and it should crash somewhere near the end of the setup process.
Based on the setup log file the tester sent he has Windows version 10.0.14393. As I wrote no traces of this problem can be found in the log, it just crashes.