GetLocaleInfo in NSIS

0

I'm trying to get locale infos in NSIS (using this code). As my system is in french, I'd hope to get a string like "fr-FR", but I'm getting chineese synbols instead :/

output

Any idea of what I'm doing wrong?

!define LOCALE_ILANGUAGE '0x1' ;System Language Resource ID     
!define LOCALE_SLANGUAGE '0x2' ;System Language & Country [Cool]
!define LOCALE_SABBREVLANGNAME '0x3' ;System abbreviated language
!define LOCALE_SNATIVELANGNAME '0x4' ;System native language name [Cool]
!define LOCALE_ICOUNTRY '0x5' ;System country code     
!define LOCALE_SCOUNTRY '0x6' ;System Country
!define LOCALE_SABBREVCTRYNAME '0x7' ;System abbreviated country name
!define LOCALE_SNATIVECTRYNAME '0x8' ;System native country name [Cool]
!define LOCALE_IDEFAULTLANGUAGE '0x9' ;System default language ID
!define LOCALE_IDEFAULTCOUNTRY  '0xA' ;System default country code
!define LOCALE_IDEFAULTCODEPAGE '0xB' ;System default oem code page

Function getLocale
    System::Call 'kernel32::GetSystemDefaultLangID() i .r0'
    System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SNATIVELANGNAME}, t .r1, i ${NSIS_MAX_STRLEN}) i r0'
    System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SNATIVECTRYNAME}, t .r2, i ${NSIS_MAX_STRLEN}) i r0'
    System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SLANGUAGE}, t .r3, i ${NSIS_MAX_STRLEN}) i r0'
    MessageBox MB_OK|MB_ICONINFORMATION "Your System LANG Code is: $0. $\r$\nYour system language is: $1. $\r$\nYour system language is: $2. $\r$\nSystem Locale INFO: $3."
FunctionEnd

Same kind of error with these constants:

!define LOCALE_SISO639LANGNAME        0x00000059   ; ISO abbreviated language name, eg "en"
!define LOCALE_SISO3166CTRYNAME       0x0000005A   ; ISO abbreviated country/region name, eg "US"

enter image description here

localization
nsis
asked on Stack Overflow Jun 29, 2020 by sinsedrix

1 Answer

1

Change GetLocaleInfoA to GetLocaleInfo. NSIS v3 will autodetect the A/W function when the t type parameter is used.

Ansi strings when interpreted as Unicode tends to look like Chinese.

answered on Stack Overflow Jun 29, 2020 by Anders

User contributions licensed under CC BY-SA 3.0