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: $!"; $WindowTitle=; #reading the chinese window title from input file chomp($WindowTitle); binmode(STDOUT, ":utf8"); print "$WindowTitle\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,$WindowTitle); if($hwnd[0]) { print "window found\n"; } else { print "window not found\n"; } print OUTFILE $WindowTitle; #==> Here perl prints out same chinese text as input to the outfile