Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:
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?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') }
Thanks,
-Phil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to "Set" unicode text to Win32::Clipboard?
by Util (Priest) on Apr 30, 2011 at 22:34 UTC | |
by Dr. Mu (Hermit) on May 01, 2011 at 00:15 UTC | |
by Dr. Mu (Hermit) on May 01, 2011 at 21:56 UTC |