comp.lang.ada
 help / color / mirror / Atom feed
From: Xavier Petit <le@vieux.pro>
Subject: Re: win32 interfacing check (SetClipboardData)
Date: Wed, 30 Aug 2017 20:41:22 +0200
Date: 2017-08-30T20:41:22+02:00	[thread overview]
Message-ID: <59a706d2$0$3723$426a74cc@news.free.fr> (raw)
In-Reply-To: <oo6nlo$dcf$1@gioia.aioe.org>

Le 30/08/2017 à 18:04, Dmitry A. Kazakov a écrit :
> It looks OK. Except that formally Wide_String is UCS-2 and Windows is 
> UTF-16.
Thank you for pointing that out.

> I would use UTF-8 encoded string as the input and recode it into UTF-16 
> to have CF_UNICODETEXT, e.g. by using MultiByteToWideChar.
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);

> 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.

If I call this procedure with Source => "𐐷𤭢" and -gnatW8 I get the 
error “literal out of range of type Standard.Wide_Character”.
Without the flag, the code compiles but the clipboard has a weird text.

So I have a working version of the code :
https://pastebin.com/raw/5ss5m5QY
...but using Wide_Wide_String/UCS-2/UTF32 as input *and* -gnatW8 flag.
So not at all like your idea (UTF-8 String and no special flag).

Thank you very much for your help


  reply	other threads:[~2017-08-30 18:41 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 [this message]
2017-08-30 21:17     ` Dmitry A. Kazakov
2017-09-01 12:51       ` Xavier Petit
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