Passing UTF-16 strings from CPack to NSIS


I’m working with a project that uses the CPack NSIS generator. I would like to display the “registered trademark” (®) symbol in the installer text, but I haven’t been able to make it work. I added the character directly to CPACK_NSIS_PACKAGE_NAME but it appears garbled in the installer text.

AFAICT the symbol is UTF-16 and NSIS would accept it, but since CMake requires UTF-8 files I can’t use UTF-16 characters in CPACK_NSIS_PACKAGE_NAME

Any help would be appreciated, thanks!


Symbols aren’t “UTF-8” or “UTF-16”. UTF-8 and UTF-16 are just different encodings of Unicode. Any Unicode character can be expressed in both UTF-8 and UTF-16.

How exactly have you added the character? Can you verify in a hex editor that the file which includes it represents it as the two bytes 0xC2 0xAE (which is the UTF-8 encoding of “®”)?

Thanks for the reply!

I inserted the character using the Sublime Text Unicode Insert addon, it shows up as “bla ®”

In the installer the ® is shown after an additional character, see attached screenshot below.


Using a Hex viewer, it does seem that the character is saved as 0xC2 0xAE and the same seems to be true for the produced project.nsi. So maybe this is a NSIS issue after all?

Could be. Unfortunately, I have zero experience with NSIS, so I can’t comment further. Hopefully someone else can chime in.

How do you output this string? Which version of NSIS are you using?

Which version of NSIS are you using?

NSIS v3.06.1

How do you output this string?

I enter the string in the CMake file (CMakeLists.txt), then run cmake which I understand will generate the NSIS file and run NSIS to create the package.

I saved the project.nsi produced by CPack (?) as UTF-16 LE with BOM and ran NSIS manually, and the character was shown correctly. It would seem that the issue is that CPack produces an UTF-8 encoded file but NSIS would need UTF-16 at least for this kind of special characters.

Keep the file as UTF-8 and add “Unicode true”, see or add UTF-BOM or upgrade to latest CMake as the latest change on the file looks like being supposed to handle this, see

Thanks for the suggestion! If I’m reading the tags correctly, the Unicode fix will be in Cmake 3.20 which is not yet released, and because of constraints in the environment I work with I can’t update to that version. What would be the way to add “Unicode true” to CMakeLists.txt so that it propagates to the .nis file?

The CPACK_NSIS_DEFINES looks promising. Probably only via CPackConfig.cmake file, though

I tried adding “Unicode true” and “!define Unicode true” at the beginning of but the result was the same.

Hmm, then the documentation of NSIS is misleading. Could be. Not the first time. :sweat_smile:

You could just convert the template to UTF-8 with BOM after CMake installation until a version with the change is available…

Yes, that worked, thank you very much for your help!