于是这样就可以正确地获取剪切板中的汉字而不需要考虑输入法了
────────────────────────┐
use Encode; │
use Win32::Clipboard; │
│
#获取中文信息 │
my $clip; │
my $test; │
$clip = Win32::Clipboard(); │
$test = $clip->GetAs(CF_UNICODETEXT); │
print encode('gbk', decode('UTF-16LE', $test)); │
────────────────────────┘
以下摘自 perldoc Win32::Clipboard:
───────────────────────────────────┐
If CF_UNICODETEXT is used, then binary Unicode data is returned. A │
perl unicode string can be generated as follows: │
│
$text = $clip->GetAs(CF_UNICODETEXT); │
$text = Encode::decode("UTF16-LE", $text); │
───────────────────────────────────┘