in reply to unicode in perl

You're viewing your source as cp1252, but the encoder expects Unicode code points. Your string is really:

0084 <-- A nameless, graphless control char 0071 LATIN SMALL LETTER Q 0079 LATIN SMALL LETTER Y 0084 007B LEFT CURLY BRACKET 007A LATIN SMALL LETTER Z 0084 00B7 MIDDLE DOT 007B LEFT CURLY BRACKET 0084 008F SINGLE SHIFT THREE 0079 LATIN SMALL LETTER Y 0084 00A3 POUND SIGN 007F DELETE 0084 008F SINGLE SHIFT THREE 007E TILDE

You could do

use Encode qw( decode ); print $FH decode('cp1252', "... the string ...");

If you do, Perl will see the string the same way you are viewing it.

However, you should save your source as US-ASCII or UTF-8. Use use utf8; if you do the latter.

Replies are listed 'Best First'.
Re^2: unicode in perl
by paramjit (Novice) on Jun 27, 2011 at 07:43 UTC
    ok here is my problem what i need to do is write the sequence generated from a function to a file which is has encoding as unicode qy{z{y~ is what i get in the file why are the ,, characters missing

      This post doesn't add anything new.

      You have text encoded using cp1252 and you are pretending it's not encoded. Decoding it will do the trick.

        output iam getting after decoding is qy{z{�y�~ actuall should be qy{z{y~