BuilderBob
18th May 2008 13:54 UTC
"????" 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
18th May 2008 14:35 UTC
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.
BuilderBob
18th May 2008 15:29 UTC
Nope. It fails for hebrew username. Succeeds for english username. :(
kichik
18th May 2008 19:32 UTC
NSIS doesn't use Unicode and so it can only handle non-Unicode paths. You can use the Unicode version:
http://www.scratchpaper.com/
BuilderBob
19th May 2008 12:40 UTC
it's a great solution but i can't use it.
govind_gk
22nd May 2008 07:35 UTC
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/
Joost Verburg
22nd May 2008 16:23 UTC
Maybe NSIS can put the short filename in the variable when the full one in Unicode?
kichik
22nd May 2008 18:14 UTC
That's what the API provides and once you get question marks, you can't safely convert it to a short name.
BuilderBob
25th May 2008 08:41 UTC
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***91;256***93;;
>memset(path, 0, 256);
if (!
SHGetSpecialFolderPathW(NULL, path, csidl, FALSE)) return FALSE;
>TCHAR shortPath***91;256***93;;
>memset(shortPath, 0, 256);
if (!GetShortPathNameW(path, shortPath, 256)) return FALSE;
>char asciiShortPath***91;256***93;;
>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.