Studio:How do I pass unicode data to the target using Perl?

From STRIDE Wiki
Jump to navigation Jump to search

To pass unicode data to the target using Perl, use the following syntax:

use strict;
Win32::OLE->Option(Warn => 3, CP => Win32::OLE::CP_UTF8);
my ($pchar, $string, $setUChar);
$pchar = "\x{f889}";
$string = "123" . $pchar . "456" . $pchar . "789" .+ $pchar;
$setUChar = $main::ascript -> Functions -> Item("setUChar") -> User;
$setUChar -> ParameterList->{str} = $string;
$setUChar -> Call();

In line 2 (Win32::OLE->Option) specifying the code page via the CP parameter is necessary in order to get Perl/COM to properly pass the pchar value as a unicode character.