comp.lang.ada
 help / color / mirror / Atom feed
From: Xavier Petit <le@vieux.pro>
Subject: Re: win32 interfacing check (SetClipboardData)
Date: Fri, 1 Sep 2017 14:51:47 +0200
Date: 2017-09-01T14:51:47+02:00	[thread overview]
Message-ID: <59a957e3$0$31612$426a74cc@news.free.fr> (raw)
In-Reply-To: <oo7a0f$1d9t$1@gioia.aioe.org>

Le 30/08/2017 à 23:17, Dmitry A. Kazakov a écrit :
> On 2017-08-30 20:41, Xavier Petit wrote:
>> Thank you but I always get the error ERROR_INVALID_PARAMETER from 
>> GetLastError, using it like this :
>>
>> UTF16_Code_Page : constant := 1200;
>>
>> Length := MultiByteToWideChar (CodePage       => UTF16_Code_Page,
>>                                 DwFlags        => MB_PRECOMPOSED,
>>                                 LpMultiByteStr => Addr (Source),
>>                                 CchMultiByte   => -1,
>>                                 LpWideCharStr  => Encoded,
>>                                 CchWideChar    => 0);
> 
> The output must be null when its length is. And it looks like 
> MB_PRECOMPOSED does not work. So (without error handling):
and I was using the wrong code page (UTF-16 instead of UTF-8).
On why MB_PRECOMPOSED does not work (from MSDN MultiByteToWideChar) :
“Note  For *UTF-8* or code page 54936 (GB18030, starting with Windows 
Vista), dwFlags must be set to either 0 or MB_ERR_INVALID_CHARS. 
Otherwise, the function fails with ERROR_INVALID_FLAGS.”

> -- 
> -- UTF-8 to UTF-16 conversion using MultiByteToWideChar
> -- 
Perfectly works, thank you very much, I can now get rid of -gnatW8 & 
Wide_Wide_String.
>>> Why should it need gnatW8 or gnata? You get characters by encoding 
>>> them, I suppose.
>> I use gnata to trigger Ada.Assertions errors, I could use the pragma 
>> Assertion_Policy (Check) too.
>> I have tested the following Wide_String : "123〠" with or without 
>> -gnatW8.
>> It only worked with, but thanks to you I know that my procedure was 
>> wrong anyway.
> 
> I see. IMO, it is a bad idea to use non-ASCII characters in the source. 
> When I need a special character I take its UNICODE code position and 
> convert that to String.
Thanks but even with Set_Clipboard (Ada.[Wide_]Wide_Text_IO.Get_Line); I 
was getting weird clipboard text without -gnatW8 flag.

  reply	other threads:[~2017-09-01 12:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29 20:28 win32 interfacing check (SetClipboardData) Xavier Petit
2017-08-30 16:04 ` Dmitry A. Kazakov
2017-08-30 18:41   ` Xavier Petit
2017-08-30 21:17     ` Dmitry A. Kazakov
2017-09-01 12:51       ` Xavier Petit [this message]
2017-09-01 13:10         ` Dmitry A. Kazakov
2017-09-02  9:38           ` Xavier Petit
2017-09-02 12:29             ` Dmitry A. Kazakov
2017-08-31  1:41   ` Randy Brukardt
2017-09-01 12:53     ` Xavier Petit
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox