I suppose doing a simple patch would be easier than trying to write a valid XS from scratch, especially since the interface doesn't change.

Where can I find the source code for the current/latest version of Win32::Clipboard? (I have ActiveState Perl, which is a binary distribution. Their "source code" download AP806_source.zip doesn't contain any file named Clipboard.*)

The MS API GetClipboardData provides no way to get the length of the data returned. Quite an unfortunate design.

Hmm, it actually returns a HANDLE to a global memory block, which is as far as I can tell the only remaining use for such a thing. In Win32 HGLOBAL's have been replaced by normal memory pointers and the documentation mostly missing.

Anyway, the Win32 function GlobalSize will return the length. Do that before copying via memcpy what GlobalLock returns, instead of using a strcpy. However, it also says, “The size of a memory block may be larger than the size requested when the memory was allocated.” so perhaps this shows the rounded-up capacity, not the requested size.

If a function returned a pointer like you suggest, rather than copying it, how will Perl know to free it eventually?

To find the bytes 00 00, why not use a regex instead of a eq substr? /.*?\0\0/ or somesuch.

—John


In reply to Re: Re: Win32::Clipboard and Unicode by John M. Dlugosz
in thread Win32::Clipboard and Unicode by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.