You are here

create a new Charset environment variable

1 post / 0 new
melvin
Offline
Last seen: 10 years 7 months ago
Joined: 2013-12-22 03:15
create a new Charset environment variable

As I checked the manual of PortableApps.comLauncher,
i didn't find a section in launcher.ini to setup charset for portable applications.

So i just wrote some customized nsis script to export charset environment variable.
Hopefully it is usefull for you.

The logic is:

Check PAL:LanguageCustom value,
if not set use English as default.

Use the result as a key to get value from section [LanguageCharsetMap]
and export the value as PAL:CharsetCustom.

If not found then use DefaultCharset in section [Language]
or UTF-8 as fallback.

Code is below:

${SegmentPre}
        ReadEnvStr $1 PAL:LanguageCustom
        ${If} $1 == ""
                ${DebugMsg} "PortableApps.com Platform language variables are missing."
                StrCpy $1 English
        ${EndIf}

        ; Get the charset
        ClearErrors
        ${DebugMsg} "Reading the Charset from launcher.ini by key `$1`."
        ${ReadLauncherConfig} $2 LanguageCharsetMap $1
        ${IfNot} ${Errors}
                ${ParseLocations} $2
                ${DebugMsg} "Setting PAL:CharsetCustom to $2 based on the [LanguageCharsetMap] section."
                ${SetEnvironmentVariable} PAL:CharsetCustom $2
        ${Else}
                ; Set the default values
                ${ReadLauncherConfig} $0 Language DefaultCharset
                ${IfNot} ${Errors}
                        ${ParseLocations} $0
                        ${DebugMsg} "Setting PAL:CharsetCustom to $0 by default."
                        ${SetEnvironmentVariable} PAL:CharsetCustom $0
                ${Else}
                        ${DebugMsg} "Setting PAL:CharsetCustom to UTF-8 by default."
                        ${SetEnvironmentVariable} PAL:CharsetCustom UTF-8
                ${EndIf}
        ${EndIf}
!macroend