An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160309/1b074da8/attachment.html>
Mailing lists / lazarus / 2016-03
Windows API calls and german Umlauts
4 messages · 3 people · –
- JJohn Landmesser 2
- MMattias Gaertner 1
- MMichael Van Canneyt 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
John Landmesser wrote 19 lines
Hi,
?
if i call a windows API function for special folder, like:
?
uses
...
shlobj;
?
var
AppDataPath: Array[0..MaxPathLen] of Char;
begin
SHGetSpecialFolderPath(0,AppDataPath,CSIDL_STARTUP,false);
end;
?
I get on a german localized Windows XP a path containing ?"\Startmen?\", but the "?" is "?" in the resulting string.
?
Howto convert ?the chars in?AppDataPath to get the "Umlauts" correct?
Use the W variant of the call, and user widechar.
var
AppDataPath: Array[0..MaxPathLen] of WideChar;
begin
SHGetSpecialFolderPathW(0,AppDataPath,CSIDL_STARTUP,false);Then convert to UTF8 using UTF8Encode() if you want to display it in a LCL application.
Michael.
An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/laz…
Show quoted text 17 lines
Hi,
if i call a windows API function for special folder, like:
uses
...
shlobj;
var
AppDataPath: Array[0..MaxPathLen] of Char;
begin
SHGetSpecialFolderPath(0,AppDataPath,CSIDL_STARTUP,false);
end;
I get on a german localized Windows XP a path containing "\Startmen?\", but the "?" is "?" in the resulting string.
Howto convert the chars in AppDataPath to get the "Umlauts" correct?
According to msdn SHGetSpecialFolderPath is not supported by Microsoft. Instead, use ShGetFolderPath.
Unit LazFileUtils has already a more sophisticated implementation for UTF8. I added
function SHGetFolderPathUTF8(ID : Integer) : String;
Mattias
Mattias Gaertner wrote 34 lines
On Wed, 9 Mar 2016 13:04:50 +0100
"John Landmesser" wrote:
> Hi,
>
> if i call a windows API function for special folder, like:
>
> uses
> ...
> shlobj;
>
> var
> AppDataPath: Array[0..MaxPathLen] of Char;
> begin
> SHGetSpecialFolderPath(0,AppDataPath,CSIDL_STARTUP,false);
> end;
>
> I get on a german localized Windows XP a path containing "\Startmen?\", but the "?" is "?" in the resulting string.
>
> Howto convert the chars in AppDataPath to get the "Umlauts" correct?
According to msdn SHGetSpecialFolderPath is not supported by Microsoft.
Instead, use ShGetFolderPath.
Unit LazFileUtils has already a more sophisticated implementation
for UTF8. I added
function SHGetFolderPathUTF8(ID : Integer) : String;
Mattias
--
_______________________________________________
Lazarus mailing list
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
that's why opensource is unbeatable:
asked a question at 14:00 h, got a new function in Lazarus at 14:15 h
Thanks Mattias and all people involved!
