Skip to content
⌘ NSIS Forum Archive

"????" in APPDATA path for non unicode (hebrew) windows username

9 posts

BuilderBob#

"????" in APPDATA path for non unicode (hebrew) windows username

Hi everyone,
Installer doesn't want to work when windows username is in non-unicode language (specifically, Hebrew).

Assuming I can't use the unicode version of nsis compiler:

Environment: Windows XP, username is in Hebrew. In Regional settings I deliberately didn't set hebrew as the language for non-unicode applications.

Problem: In paths such as $APPDATA, NSIS replaces the user name with question marks.

Hint: The command line tool (command, not cmd) displays a short path with a number instead of the hebrew username (see image).

How can I get this number programmatically? Is there another solution to the question marks problem, without using unicode-nsis?

Thanks.
Animaether#
You can try...

4.9.3.9 GetFullPathName
[/SHORT] user_var(output) path_or_file
Assign to the user variable $x, the full path of the file specified. If the path portion of the parameter is not found, the error flag will be set and $x will be empty. If /SHORT is specified, the path is converted to the short filename form.
kichik#
NSIS doesn't use Unicode and so it can only handle non-Unicode paths. You can use the Unicode version:

New Site - Aug 11, 2009 1:0:19 PM
govind_gk#
Originally posted by kichik
NSIS doesn't use Unicode and so it can only handle non-Unicode paths. You can use the Unicode version:

http://www.scratchpaper.com/
kichik#
That's what the API provides and once you get question marks, you can't safely convert it to a short name.
BuilderBob#
I coded a C/C++ solution last week and now calling it from my installer. This is the important part of the function:

// csidl is int value for some user folder.
TCHAR path[256];
memset(path, 0, 256);
if (!SHGetSpecialFolderPathW(NULL, path, csidl, FALSE)) return FALSE;
    
TCHAR shortPath[256];
memset(shortPath, 0, 256);
if (!GetShortPathNameW(path, shortPath, 256)) return FALSE;
char asciiShortPath[256];
memset(asciiShortPath, 0, 256);
strcpy(asciiShortPath, ATL::CT2A(shortPath)); 
I could only make it work using the unicode version of SHGetSpecialFolderPath and GetShortPathName, and only then converting to ANSI.