Search code examples
unicoderegistryinno-setup

Unicode Values in Registry (Inno Setup 5)


I need to be able to store certain Unicode characters in a few of my registry keys, but am unable to find the syntax to do this in an .iss file. I am using the Unicode version of Inno Setup

The Inno Setup site says this about Unicode values:

you can for example instead use encoded Unicode characters to build Unicode strings (like S := #$0100 + #$0101 + 'Aa';), or load the string from a file using LoadStringsFromFile, or use a {cm:...} constant.

For example one of the one's I want to enter is the degrees Fahrenheit symbol () which is #$2109.

I can't put #$2109 directly into the value string because that just prints out that text. I tried to create a #define constant but it doesn't recognize the # and $ characters.

So I want:

[Registry]
Root: HKLM; Subkey: "MyPath"; ValueType string; ValueName: "MyName; \
    ValueData: "Temperature [℉]"

but obviously I cannot put it in directly.

How do I get Unicode characters into the registry section, either directly or via some variable/constant, I'm fairly new to Inno Setup.

Thanks in advance!


Solution

  • Just make sure your .iss file is UTF-8 encoded with BOM.

    Then you can use UTF-8 strings directly in it (with Unicode version of Inno Setup), as the documentation says:

    Unicode Inno Setup supports UTF-8 encoded .iss files (but not UTF-16).

    [Registry]
    Root: HKLM; Subkey: "MyPath"; ValueType: string; ValueName: "MyName"; \
        ValueData: "Temperature [℉]"
    

    (note that the entry syntax in your question is wrong, you are missing a colon and a quote)

    enter image description here


    An easy way to save the file in UTF-8 with BOM:

    • Open the .iss file in Inno Setup Compiler GUI.
    • Go to File > Save Encoding and select UTF-8.
    • Save the file.

    You need to do this before inserting your UTF-8 string. Also note that the Inno Setup Compiler editor cannot display the , but it will still work ok, when compiled.


    Another way is:

    • Open the .iss file in Windows Notepad.
    • Go to File > Save As.
    • Select UTF-8 in Encoding drop down box.
    • Click Save.

    Windows Notepad can display the (with an appropriate font, like the default Consolas or Lucida Console).