I'm working on a program that interacts with another Windows program (an editor). It selects all of the text (possibly unicode) under one tab, copies it to the clipboard, retrieves it from the clipboard, adds some markup, then pastes the marked-up text back to the other program under a new tab via the clipboard. At least, that's what's supposed to happen. Here's a skeletal version of the
Markup routine that simply echoes back to the clipboard the text that it reads. The
prints are there to monitor the text conversions:
sub Markup {
$textarea = (grep {IsWindowVisible($_)} (FindWindowLike($ide, unde
+f, qr/Edit/, undef, undef)))[0];
SetForegroundWindow($textarea);
SendKeys('^a^c{HOME}');
my $source = $clip->GetAs(CF_UNICODETEXT);
print map {sprintf("%2.2X ", ord($_))} (split //, $source); print
+"\n\n";
$source = Encode::decode("UTF16-LE", $source);
print map {sprintf("%2.2X ", ord($_))} (split //, $source); print
+"\n\n";
$source = Encode::encode("UTF16-LE", $source);
print map {sprintf("%2.2X ", ord($_))} (split //, $source); print
+"\n\n";
$clip->Set($source);
SendKeys('^n^v')
}
According to the routine's output, the conversions are done correctly. The problem occurs when trying to write the text back to the clipboard. It appears to be treated as a zero-terminated byte string, rather than
UTF16-LE-encoded text. What appears to be needed is a
SetAs method, but there is none. Is there any way I can signal that the text being written to the clipboard is supposed to be
UTF16-LE and not ASCII?
Thanks,
-Phil
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.