Old 19th July 2019, 10:26   #1
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
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:
code:

!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?
ilmars is offline   Reply With Quote
Old 19th July 2019, 11:39   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
We need more information.

Are you changing the default MUI text?

Windows version? NSIS version?

Minimal example code?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th July 2019, 11:45   #3
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
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?
ilmars is offline   Reply With Quote
Old 19th July 2019, 12:41   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th July 2019, 14:15   #5
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
> 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:

code:

Error adding version information: Unicode conversion failed
Error - aborting creation process

ilmars is offline   Reply With Quote
Old 19th July 2019, 14:38   #6
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
I tested iconv on the machine, it seems to be working (converted a iso-8859-1 file to utf8 successfully)
ilmars is offline   Reply With Quote
Old 19th July 2019, 15:00   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
The version information needs to convert the VIAddVersionKey strings. Are those non-ASCII strings?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th July 2019, 15:06   #8
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
They should be ASCII.
Just in case, I tried changing the strings to static values like this:
code:

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.
ilmars is offline   Reply With Quote
Old 19th July 2019, 21:56   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd July 2019, 07:50   #10
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
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):
code:

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 is offline   Reply With Quote
Old 22nd July 2019, 07:54   #11
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
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):
code:

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.
ilmars is offline   Reply With Quote
Old 22nd July 2019, 12:35   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
v2.46 is 10 years old so you might have more luck using a environment from that era. Did you try v3.x?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd July 2019, 13:29   #13
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
3.03 also fails
code:

!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

ilmars is offline   Reply With Quote
Old 22nd July 2019, 13:37   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
Quote:
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd July 2019, 14:41   #15
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
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.
ilmars is offline   Reply With Quote
Old 22nd July 2019, 16:22   #16
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 23rd July 2019, 10:22   #17
ilmars
Junior Member
 
Join Date: Jul 2019
Posts: 10
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!
ilmars is offline   Reply With Quote
Old 23rd July 2019, 17:22   #18
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
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

Quote:
iconv_t cd = iconv_open("UCS-2LE", cp);
if (cd == (iconv_t) -1) {
return 0;
}
to
Quote:
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

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

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

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

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
posix, unicode

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump