1. Rolf Knaden
  2. PowerBuilder
  3. Wednesday, 5 January 2022 13:33 PM UTC

Hi.
I have problems to get the correct utf-filename of files, dropped to may window.

I am using DragQueryFileA to get the filenames, that are dropped to my window. It is implemented like this:
    function ulong DragQueryFileA( ulong ul_Drop, ulong ul_index, ref string LPTSTR, ulong cb ) LIBRARY "shell32.dll" alias for "DragQueryFileA;Ansi"
In that implementation, DragQueryFileA provides the Ansi-names.
But I have filenames with german special characters like this "C:\temp\MeinMülleimer.png" dropped.
The name provided by DragQueryFileA then is "C:\temp\MeinMu¨lleimer.png".

If already remove the "...;Ansi" in the external function.
Then I get a string like this "㩃瑜浥屰敍湩畍沨敬浩牥瀮杮" (think it's 3-byte-characters).

I have written a small function to convert the value:
    string ls_filename
    ls_filename = string( blob(as_filename, EncodingUTF16LE! ), encodingUTF8! )
This returns ls_filename like that: "C:\temp\MeinMu¿lleimer.png", which also is not the correct name.

How do I get the correct name of the dropped file?

mike S Accepted Answer Pending Moderation
  1. Wednesday, 5 January 2022 13:43 PM UTC
  2. PowerBuilder
  3. # 1

Have you tried DragQueryFileW vs DragQueryFileA - The W version is unicode

 

 

Comment
  1. Rolf Knaden
  2. Wednesday, 5 January 2022 14:54 PM UTC
That's it.

Thank you for that quick answer, Mike.

Regards

Rolf
  1. Helpful
  1. John Fauss
  2. Wednesday, 5 January 2022 15:17 PM UTC
Rolf - The naming convention for Windows API functions that work with character/string values is that those whose names end with a capital "A" accept & return ANSI-encoded (single-byte/character) data. Those whose names end with a capital "W" (for "Wide") accept & return Unicode-encoded (Unicode 16LE, or Little Endian, two bytes/character) data.

Including ALIAS FOR ";xxxxxx;ansi" in the PowerBuilder external function declaration tells PowerBuilder to perform the encoding translation between Unicode (what PB uses) and ANSI (what the ANSI-flavor of the API function uses). Both Windows and PB use Unicode 16LE encoding internally, Windows provides ANSI-encoded versions of its API functions for legacy compatibility.
  1. Helpful 2
  1. Miguel Leeuwe
  2. Thursday, 6 January 2022 05:18 AM UTC
Hi Rolf, please mark your question as "Resolved".
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.