Menu

#160 Unicode Support for NSIS

Stable
closed-accepted
NSIS (71)
5
2014-03-31
2007-09-14
Jim Park
No

I based my work on NSIS 2.29
and my general approach has been via the use of TCHAR type macros to
allow the same source to target both ANSI and Unicode. Of course, it
wasn't as easy as just sed'ing 80K lines of code and changing all the
chars to TCHARs. It did require modifications to the appropriate
parts of the engine as well as the contributed plugins. I've worked
as fast as I could for the past month and half, working full time on
this.

The resulting NSIS app when built as Unicode is *purely* Unicode. The
NSIS scripts must be encoded as utf-16le which notepad.exe will easily
create by setting the encoding to "Unicode" when saving the text file.
Not only are we able to support Unicode-only languages like Georgian
and Indian dialects, we can write our NSIS scripts while keeping our
developers' Windows machines set to the English code page--a definite
convenience. We can now generate an installer with multiple languages
/ scripts on the same dialog box!

As for the size of the exehead, it remains very small. I believe
there's only about a 1.5 kbytes difference between the ANSI and the
Unicode versions. The difference being mostly driven by the fact that
static strings are now double the size. But we're still talking about
less than 40KB exehead. Not bad, if you ask me. Having gotten pretty
familiar with the code, I also fixed bugs where I found them.

I want to reiterate that the source code can generate both ANSI and
Unicode versions of NSIS. Generating the Unicode version is done by
using the UNICODE=yes as a scons parameter. The ANSI version also has
some bug fixes in the engine – most notably where allocation of
buffers was not big enough and there was some trouncing of memory.
I've also structured the installation of NSIS such that the Unicode
and ANSI versions can coexist on the same machine—a requirement we
have internally as well.

I know that adding Unicode support is not just a couple of days of
work. It's a pretty massive project. So I hope that what I'm
providing here will help keep NSIS in the lead as the de facto
installation solution for the open source community.

The source is here: http://www.scratchpaper.com/source.zip
The Unicode version of NSIS is here:
http://www.scratchpaper.com/nsis-05-Sep-2007.cvs-unicode-setup.exe
And the ANSI version built on the same code base as the Unicode one is
here: http:://www.scratchpaper.com/nsis-05-Sep-2007.cvs-setup.exe

Some cautionary notes:
I've done as much testing as I could but I'm sure there are bugs in areas where I did not
exercise the code. Some of the scripts are suspect because I did a
cursory conversion of them without testing them thoroughly.

I developed on VS2005 on Windows XP. I've pulled what I needed into
my own tchar.h which I included in the source and tstring.h has other
convenient ANSI / Unicode classes of my own devising for C++. I don't
think NSIS will build correctly on other platforms or other compilers
without some additional changes. I also do not know that any Unicode
installers generated will work on Windows 95/98. Because we don't
support those platforms, I did not test to make sure the installers
generated will work on those older platforms.

I also did not modify the unit testing code which should probably be done.

Anyway, thank you guys for the hard work in keeping NSIS the best
installer solution. If you have questions for me, please e-mail me.
I've also just registered on your NSIS Wiki as 'jimpark.'

Sincerely,
Jim Park

P.S. I was hoping to get this done before NSIS 2.30 came out so that
there would be less diversion from the trunk. But you guys work too
fast. Well, I don't think the code has diverged too badly…

Discussion

  • Jim Park

    Jim Park - 2007-11-22

    Logged In: YES
    user_id=1875824
    Originator: YES

    Merged code changes to NSIS 2.33. The source and built binaries can be found in http://www.scratchpaper.com. New in this release is that the language names are in their vernacular languages. For example, Korean is 한국어. Please check out the site for a screenshot of what can be done.

     
  • Paul Wise

    Paul Wise - 2008-07-06

    Logged In: YES
    user_id=35028
    Originator: NO

    The patch is being discussed here:

    http://forums.winamp.com/showthread.php?s=&threadid=277381

     
  • Anders

    Anders - 2013-03-28
    • status: open --> closed-accepted
     

Log in to post a comment.