From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FROM_SUSPICIOUS_NTLD autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed2-a.proxad.net!nnrp2-1.free.fr!not-for-mail Subject: Re: win32 interfacing check (SetClipboardData) Newsgroups: comp.lang.ada References: <59a5ce50$0$7168$426a74cc@news.free.fr> From: Xavier Petit Date: Wed, 30 Aug 2017 20:41:22 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Message-ID: <59a706d2$0$3723$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 30 Aug 2017 20:41:22 CEST NNTP-Posting-Host: 78.217.21.11 X-Trace: 1504118482 news-3.free.fr 3723 78.217.21.11:55279 X-Complaints-To: abuse@proxad.net Xref: news.eternal-september.org comp.lang.ada:47841 Date: 2017-08-30T20:41:22+02:00 List-Id: 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