简体   繁体   中英

NSIS "Bad text encoding" compilation error from _EndSwitch macro

We've been using NSIS 2.50 for some time now and I'm trying to update to the newest 3.0x version. I'm using Unicode true . I've ran into an issue, which I'm failing to understand. We use a switch for mapping native language names to language IDs, more or less like this:

${Switch} "${LANGNAME}"
    ${Case} "${LANGFILE_ALBANIAN_NAME}"
        StrCpy $0 "${LANG_ALBANIAN}"
        ${Break}
    ${Case} "${LANGFILE_ARABIC_NAME}"
        StrCpy $0 "${LANG_ARABIC}"
        ${Break}
    ; Other cases
${EndSwitch}

The error I'm getting from compilation:

Bad text encoding: C:\Users\me\AppData\Local\Temp\nst9352.tmp:9
!include: error in script: "C:\Users\me\AppData\Local\Temp\nst9352.tmp" on line 9
Error in macro _EndSwitch on macroline 9

The temporary file is apparently created by LogicLib, which then tries to include it. The file really doesn't have any valid Unicode encoding (I'm posting just a snippet from the file):

!insertmacro _== `$2` `Shqip` _LogicLib_Label_433 ""
!insertmacro _== `$2` `???????` _LogicLib_Label_434 ""
!insertmacro _== `$2` `Catal�` _LogicLib_Label_441 ""

The strings with invalid UTF-8 characters seem to be encoded in various ANSI encodings (some seem to be Western European, some Central European etc.), while the question marks are saved as real question marks (0x3F). ${LANGFILE_NLFID_NAME} is defined in language files as native name using the LANGFILE macro from LangFile.nsh . I looked at the language files and they are encoded in UTF-8 BOM and look all right. So it looks like the native name is re-encoded to ANSI or something for ${LANGFILE_NLFID_NAME} ?

I'm pretty sure I'm making some stupid mistake, but I can't really figure out what it is.

Looks like a bug, I'll try to fix it for the next release.

Since you are not using the fall-through Switch feature you can just use Select or If/ElseIf instead:

${Select} "${LANGNAME}"
    ${Case} "${LANGFILE_ALBANIAN_NAME}"
        DetailPrint LANG_ALBANIAN
    ${Case} "${LANGFILE_ARABIC_NAME}"
        DetailPrint LANG_ARABIC
${EndSelect}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM