Skip to content
⌘ NSIS Forum Archive

Unicode conversion error 2.4x POSIX

18 posts

ilmars#

Unicode conversion error 2.4x POSIX

Hi!

I'm trying to package an old project, which used to work but now suddenly doesn't.
It seems to have something to do with MUI.

Heres the error:

!insertmacro: MUI_PAGE_WELCOME
Error while changing UI: Unicode conversion failed
Error in macro MUI_INTERFACE on macroline 54
Error in macro MUI_PAGE_INIT on macroline 3
Error in macro MUI_PAGE_WELCOME on macroline 5
I've been jumping from one error to the next for the past few days, but am now stuck with this.
Does anyone have any clue how to solve this?
Anders#
We need more information.

Are you changing the default MUI text?

Windows version? NSIS version?

Minimal example code?
ilmars#
This is the full nsis template script: https://pastebin.com/raw/YUYLvSWM

> Are you changing the default MUI text?
Yes, it looks like some texts are being changed.

> Windows version? NSIS version?
This is where it gets tricky, im trying to cross-compile for windows on openSUSE. Using NSIS 2.46. I've also tried 3.03 and a whole other sea of errors occured. Im sure this was previosly working on 2.x.

Is there anything else I can provide that could help?
Anders#
winchar.cpp is the only place in 2.46 that can throw that error AFAIK. ResourceEditor.cpp will probably use it when changing the MUI dialog resource.

Did you compile all of NSIS on your linux machine? Try to copy the Contrib folder from a Windows install, your UI exe files might be broken somehow.

You might also want to investigate if iconv on your system is working correctly because NSIS uses that on POSIX when converting to/from Unicode.
ilmars#
> Try to copy the Contrib folder from a Windows install, your UI exe files might be broken somehow.

This seemed to work. Well, at least I got some new errors associated with some missing libraries. I fixed those errors and I'm now back to a similar error like before:


Error adding version information: Unicode conversion failed
Error - aborting creation process
ilmars#
I tested iconv on the machine, it seems to be working (converted a iso-8859-1 file to utf8 successfully)
Anders#
The version information needs to convert the VIAddVersionKey strings. Are those non-ASCII strings?
ilmars#
They should be ASCII.
Just in case, I tried changing the strings to static values like this:

VIProductVersion "1.1.1.1"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "test"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "test"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "1.1.1.1"
and the same error still occurs.
Anders#
Can you test it on Windows?

If not, try adding some "printf"s to MultiByteToWideChar in \Source\Util.cpp. I'm guessing iconv is failing somehow.

What is your locale set to?
ilmars#
Can you test it on Windows?
I'm afraid setting that up would take very long, I'd rather avoid it if possible.


If not, try adding some "printf"s to MultiByteToWideChar in \Source\Util.cpp. I'm guessing iconv is failing somehow.
I'm getting compilation errors (previously nsis was installed from an rpm) and I'm not confident that I'm compiling it correctly.

I'm running this (still NSIS 2.46):

scons XGCC_W32_PREFIX=i686-w64-mingw32- SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all NSIS_CONFIG_CONST_DATA_PATH=no PREFIX=/home/user/client/nsis-2.46-src install-compiler
see the errors here
(I've added the -libstdc++ flag but to no avail)


What is your locale set to?
It was set to POSIX, tried setting en_US.UTF-8 and building again but that didn't help.
ilmars#
Can you test it on Windows?
I'm afraid setting that up would take very long, I'd rather avoid it if possible.


If not, try adding some "printf"s to MultiByteToWideChar in \Source\Util.cpp. I'm guessing iconv is failing somehow.
I'm getting compilation errors (previously nsis was installed from an rpm) and I'm not confident that I'm compiling it correctly.

I'm running this (still NSIS 2.46):

scons XGCC_W32_PREFIX=i686-w64-mingw32- SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all NSIS_CONFIG_CONST_DATA_PATH=no PREFIX=/home/user/client/nsis-2.46-src install-compiler
see the errors here
(I've added the -libstdc++ flag but to no avail)


What is your locale set to?
It was previously set to POSIX, tried building with en_US.UTF-8 but that didn't help.
Anders#
v2.46 is 10 years old so you might have more luck using a environment from that era. Did you try v3.x?
ilmars#
3.03 also fails

!undef: "_UAC_ParseDefineFlags_orin_f2" not defined!
Error in macro _UAC_ParseDefineFlags_orin on macroline 12
Error in macro _UAC_ParseDefineFlags_Begin on macroline 6
Error in macro _UAC_ParseDefineFlagsToInt on macroline 1
Error in macro UAC_AsUser_Call on macroline 5
Error in macro UAC_AsUser_ExecShell on macroline 11
Error in script "/root/client/build-win32/_CPack_Packages/unused/NSIS/project.nsi" on line 252 -- aborting creation process
Anders#
Originally Posted by ilmars View Post
3.03 also fails
That looks like a totally different issue. And it is a 3rd-party deprecated plug-in. Can we maybe focus on makensis itself first?
ilmars#
After commenting out some (UAC related) lines, v3.03 built the installer successfully. The installer doesn't work correctly though (due to the UAC plugin).

I'm guessing that the unicode conversion code has changed since v2.46, or it is being skipped entirely as the strings are already ASCII?

I think I'll have to replace the deprecated code and stick with v3.03 because the UAC plugin issue is clear but the v2.46 route would still need further debugging and at this point, I'm expecting another error to show up after that one is fixed. Or, maybe you know a better way?

I'm not sure why the UAC plugin was used in the first place. I assume that the installers demand elevated privileges by default, otherwise how would they write to Program Files? 😕 My best uneducated guess is that its main purpose is launching the installed installed program (not as admin) after the install has finished and I could certainly do without that.
Anders#
2.x is not Unicode but some of the .exe resources needs Unicode strings. Unless you need to support Win95/98/ME you should move to 3.x. 2.46 used to work on POSIX but like I said, it is 10 years old and compilers and libraries have changed since then.

I would recommend that you dump the UAC plug-in but I can still take a look to see if there is an easy fix. On your end, you can just remove the Run checkbox from the Finish page if that is the only reason you are using it.
ilmars#
I've removed the UAC related code and everything seems to be working just fine.

It's truly inspiring to see a developer still care for an open source project for so long! TBH I didn't even expect to get any replies to this thread, let alone help from one of the main devs... Anyway, I've sent you a donation on paypal as an expression of my gratitude. It ain't much - but hey, lunch is on me 😉

Thank you for all your help!
Anders#
A couple of things you can try for 2.x:

In util.cpp:

* Change "CP%d" to "CP%d//TRANSLIT" in create_code_page_string.

* in MultiByteToWideChar, change

iconv_t cd = iconv_open("UCS-2LE", cp);
if (cd == (iconv_t) -1) {
return 0;
}
to
iconv_t cd = iconv_open("UCS-2LE", cp);
if (cd == (iconv_t) -1) cd = iconv_open("UTF-16LE", cp); // Retry with UTF
if (cd == (iconv_t) -1) {
fprintf(g_output,"iconv_open failed\n"),fflush(g_output);
return 0;
}
and

if (nsis_iconv_adaptor(iconv, cd, &in, &inbytes, &out, &outbytes) == (size_t) -1) {
iconv_close(cd);
return 0;
}
to

if (nsis_iconv_adaptor(iconv, cd, &in, &inbytes, &out, &outbytes) == (size_t) -1) {
iconv_close(cd);
fprintf(g_output,"nsis_iconv_adaptor failed\n"),fflush(g_output);
return 0;
}
Which version of the UAC plug-in are you using?

Make sure UAC.nsh contains

!ifdef _UAC_ParseDefineFlags_orin_f2
!undef _UAC_ParseDefineFlags_orin_f2
!endif
at the end of _UAC_ParseDefineFlags_orin