Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Perl Encoding/Decoding Doubt: From a Novice

by Khen1950fx (Canon)
on Jul 04, 2013 at 14:01 UTC ( [id://1042458]=note: print w/replies, xml ) Need Help??


in reply to Perl Encoding/Decoding Doubt: From a Novice

Since you're are reading a Word file, you want to use the reverse: encode_utf8 and encode instead of decode. I use binmode to print the set of characters 'as is'.
#!/usr/bin/perl -l use strict; use warnings; use Encode qw(encode encode_utf8); $| = 1; my $str = "Çirçös"; $str = encode_utf8($str); print $str; my $str1 = "Çirçös—"; $str1 = encode('UTF-8', $str1); binmode STDOUT, ":encoding(UTF-8)"; print $str1;

Replies are listed 'Best First'.
Re^2: Perl Encoding/Decoding Doubt: From a Novice
by ppremkumar (Novice) on Jul 04, 2013 at 15:34 UTC

    I tried the coding you provided, but I get the below output.

    Çirçös Çirçös—

    If it helps, I am using Windows: Windows 7 Professional 32-bit (6.1, Build 7601) Service Pack 1 (7601.win7sp1_gdr.130318-1533)

      My bad. I was thinking of Linux. How about this:
      #!/usr/bin/perl -l use warnings; use strict; use Encode qw(encode_utf8); $| = 1; binmode STDIN, ":encoding(UTF-8)"; my $str = 'Çirçös'; $str = encode_utf8($str); print "$str"; my $str1 = 'Çirçös—'; $str1 = encode_utf8($str1); binmode STDOUT, ":encoding(UTF-8)"; print "$str1";
      I'm on Fedora, so I'm flying blind. Does that help?

        It still doesn't work.

        I tried the below coding as well, but to no avail.

        use open ':std' => ':locale'; # Error: Cannot figure out an encoding to use

        Windows doesn't seem to accept the above coding as well.

        Now, should I go about changing those characters to HTML entities in Microsoft Word itself and then try doing the conversion, in which case there shouldn't be any problem.

        But I am still hopeful there is another way

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1042458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found