http://www.perlmonks.org?node_id=1011573

cstar has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I want to use Win32::Guitest in non english languages(say chinese) where window titles appear in chinese. If i mention the window title directly in findwindow function as -->FindWindowLike(undef,"TextInChinese") perl is able to find the window. But i have to read the window titles from a unicode file and then have to use it in Findwindowlike function. ie: I have a file with name titles.txt encoded in UTF8 which has the title of window in chinese. Please guide me in how to read the file and give the input to Findwindowlike function

Replies are listed 'Best First'.
Re: using win32::guitest in non english OS
by Anonymous Monk on Jan 04, 2013 at 07:40 UTC

      I have some chinese text in a inputfile encoded in utf8 format. I just want to read the text from the file and keep that text in a variable for further use. But when i am trying to print the line which is read, i am getting some text in Chinese, but different from what is present in the input file. Plese guide me in how to get the exact text present in input file

      use File::BOM; use Cwd; use Encode; use Encode::Detective; use strict; use warnings; my $filename=cwd().'/saml.txt'; File::BOM::open_bom(FH, $filename, ':utf8'); my $line=<FH>; my $encoding = Encode::Detective::detect ($line); print "encoding - $encoding\n"; binmode(STDOUT, ":utf8"); print "*$line*\n";

        But when i am trying to print the line which is read, i am getting some text in Chinese, but different from what is present in the input file.

        What do you mean "getting?"

        Have you checked the bytes, how are they different?

        Try ":encoding(UTF-8)"

        see Re^2: Perl / FileFind or ...