use Encode; use Win32::GuiTest qw(FindWindowLike); open(MYFILE, '<:encoding(UTF-8)',"saml.txt") || die "cannot open: $!"; open(OUTFILE,'>:encoding(UTF-8)',"out.txt") || die "cannot open: $!"; $line=; #reading the chinese text from input file chomp($line); binmode(STDOUT, ":utf8"); print "$line\n"; #===> Here perl prints out some chinese text to the command console, but different from what is given in input file my @hwnd=Win32::GuiTest::FindWindowLike(undef,$line); if($hwnd[0]) { print "window found\n"; } else { print "window not found\n"; } print OUTFILE $line; #==> Here perl prints out same chinese text as input to the outfile #### use Encode; use Win32::GuiTest qw(FindWindowLike); $line="***Winow title in chinese**"; binmode(STDOUT, ":utf8"); print "$line\n"; #===> Here perl prints out some chinese text to the command console, but different from what is given in input file my @hwnd=Win32::GuiTest::FindWindowLike(undef,$line); if($hwnd[0]) { print "window found\n"; } else { print "window not found\n"; }