Specifying non-ASCII characters for NSIS' LangString - nsis

I'm using NSIS to generate a Windows' installer for my application. I'd like a multi-lingual installer. I'm using LangString for specifying strings.
However, the documentation doesn't seem to say how one should encode a non-ASCII character. For example, to use the German word "benötigt" (where the 'o' has an umlaut), how should I encode the ö?

It's just easier to use the Unicode version of NSIS. The entire problem then goes away.

I assume we are talking about the ANSI version of NSIS here...
The 2nd parameter to LangString is the language id (You can generate one with NSIS\Bin\MakeLangId.exe, but since you probably already use the MUI_LANGUAGE macro or LoadLanguageFile, ${LANG_GERMAN} etc will be defined for you)
NSIS does not really care how the string is encoded, but if you have a lot of strings in different languages, it is probably a good idea to put the LangString commands in external files that you can !include. This way you can edit different language files with different codepages and text editors.

If you want to compile the UNICODE strings by the ANSI version of NSIS compiler, then you have to put such strings in separate .nsi file with UCS-2 LE BOM (lookup it with Notepad++) format and directly include that.
I've using particularly english and russian versions of such files at the end of a main.nsi:
!ifdef LANG_ENGLISH
!include "${PROJECT_SRCS_ROOT}\lang_en.nsi"
!endif
!ifdef LANG_RUSSIAN
!include "${PROJECT_SRCS_ROOT}\lang_ru.nsi"
!endif

if you can not use the unicode version of nsis, you could encode your text in latin-1 (ISO 8859-1) which can be used to produce these umlauts as ü,ä,ö

Related

Inno Setup : Unicode in the language files are not being converted and displayed as it is

I am using Inno Setup version 6 and earlier I was using unofficial translation files from Inno Setup website for Korea and Chinese traditional languages they worked fine but we have our own translation team which verified the translation and converted them into Unicode. But the characters are not being converted on final setup and being displayed as it is.
Chinese traditional Language file can be downloaded from this link
UPDATE: Seems like Inno Setup does not have support for UTF-16 (Unicode Inno Setup)
Is there any option within Inno Setup to make it work?
Your ISL file has been wrongly converted to UTF-8 and contains only code characters instead of real ones.
I have converted few strings and resaved the file:

how to use only unicode in nsis?

I am evaluating nsis. I want to create an installer (using mui2) which will use the provided Unicode strings (for titles, buttons, labels etc.) and not to use any "localization".
For example: the application title contains unicode characters from different languages (let's say: "Λεξικό-Dictionary-Речник" will be the whole title, regardless of the user "language")
Is there a simple way to use the provided exact unicode strings independently of the mui language?
EDIT (as commented) :
The above is about having own Unicode strings for buttons and, in general, UI text (no localization). Is not about any source (or destination) "filename" or "path".
NSIS will not translate the name, just make sure you save the .NSI source file as UTF-8 with BOM/Signature or UTF-16 with a BOM if you use non-ASCII characters.
Unicode True
Name "Λεξικό-Dictionary-Речник"
OutFile "MyInstaller.exe"
InstallDir "$ProgramFiles\$(^Name)"
!include MUI2.nsh
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
Section
SetOutPath $InstDir
File /r "c:\myfiles\*.*"
SectionEnd
It is also possible to manually construct Unicode characters from Unicode code points:
Section
MessageBox MB_OK "${U+2115}SIS" # DOUBLE-STRUCK CAPITAL N + "SIS"
SectionEnd
The problem was I saved the file as UTF8 (!!!). After saving the file from Notepad as Unicode the problem disappeared.

How to make own language file in NSIS?

I want to make my own language file for my installer. I want to make my installer which will support two languages "English" and "Hindi". But there is no language file for hindi. So I want to make my own language file for hindi. Can anyone tell me how to make it and how to link it with NSIS? And what is ".nlf" files e.g "English.nlf" present in the NSIS Contrib folder?
The .nlf files inside Contrib\Language files are storing all default dialogs used by NSIS. The .nsh files in the same folder are used by installers with Modern UI. I'd clone the files for English translation (or any other language you prefer as starting point) and change all the strings inside.
For your convenience, there are packages available for Sublime Text and Atom, that let you jump between each translation field.
As suggested by idleberg, you just copy one of the .nlf and .nsh files and translate the strings but you are in luck, the NSIS fork already has a almost complete translation.

Does VS C++ Character Set compiler setting influence character encoding?

Are there any direct consequences of toggling between Unicode, MBCS, and Not Set for the VS C++ compiler settings Configuration Properties->General->Character Set, apart from the setting of the _UNICODE, _MBCS and _T macros (which then, of course, indirectly has consequences through the generic text mappings for string functions)?
I am not expecting it to, but since the documentation says "Tells the compiler to use the specified character set", I'd like to be certain that, specifically, it doesn't have any influence on how any literal non-ASCII text put into strings or wstrings is encoded? (I am aware that non ASCII literals in the source is not portable, but am maintaining a solution where this is used heavily.)
Thanks in advance.
No, it only affects the macro definitions. Which in turn can have wide-ranging effects on anything from <tchar.h> or the Windows T string pointer types (LPTSTR etc).
If you use any non-ASCII codes in your string literals then you depend heavily on the way the compiler decodes the text in your source code file. The default encoding it assumes is your system code page as configured in Control Panel + Regional and Language options. This will not work well when your source code file ever strays too far away from your machine. Specifying utf8 with a BOM is wise so this is never a problem. In the IDE that's set with Save As, arrow on the Save button, "Save with encoding", pick 65001. Support for utf8 encoded source code files is spotty in older versions of C++ compilers.
For unadorned strings, C++ follows C: it's ASCII. If you wrap them with anything, the game changes.
C++0x standardises Unicode strings. UTF in particular. This is a new feature.

How to change the cultural info to English in vc++ 6.0?

I have a converter code which will convert one form of data to another format. But this exe is now running in French OS. While reading the file, decimal separator and other thing will vary according to French OS.
For example, in French, the decimal separator is "," instead of ".". so how to change the cultural info to English while reading data in vc++ 6.0 and not in .NET.
Long time since I needed to do this but I think it's just to set the locale using setlocale.
So something like:
setlocale( LC_ALL, "English" );

Resources