Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Different behaviour in characters in string vs. array?

by ccn (Vicar)
on Dec 10, 2008 at 21:22 UTC ( [id://729512]=note: print w/replies, xml ) Need Help??


in reply to Different behaviour in characters in string vs. array?

Add a line use encoding 'utf8'; and remove no warnings;

See Поддержка Unicode for explanations

Replies are listed 'Best First'.
Re^2: Different behaviour in characters in string vs. array?
by ikegami (Patriarch) on Dec 10, 2008 at 21:27 UTC
    encoding has problems, which is why I recommended use utf8;

      Good point.

      So to avoid encoding bugs and warnings at output about "Wide character in print" one can write:

      use utf8; $ENV{LANG} = 'ru_RU.UTF-8'; use open IO => ':locale'; # I tried ':utf8' instead but got warnings

        The bugs to which you linked are Encode's, not encoding. While they may effect use encoding, I was referring to use encoding's proper flaws. Now, I can't remember exactly what they were, but you can search the P5P mailing list for the conversation.

        Depending on what you want to do,

        # Use expected encoding for STDIN/OUT/ERR use open ':std', ':locale'; # Use UTF-8 for STDIN/OUT/ERR use open ':std', ':encoding(UTF-8)'; # Use UTF-8 for file IO use open IO => ':encoding(UTF-8)';

        :utf8 has a security vulnerability for input.

Re^2: Different behaviour in characters in string vs. array?
by oko1 (Deacon) on Dec 10, 2008 at 22:27 UTC

    Removing the "no warnings" would produce a warning. There's a '#' inside the 'qw//', and Perl gets a bit unhappy about those.

    ben@Tyr:~$ perl -wle'print qw/#/' Possible attempt to put comments in qw() list at -e line 1. #

    --
    "Language shapes the way we think, and determines what we can think about."
    -- B. L. Whorf
      In fact there are no # characters in the code. They appear on OP post because of PM can not display unicode characters inside of <code> block. The real code is:
      @kmap = qw/A B V G D E + J Z I Y K L M N O P R S T U F H C X ! @ # $ % ^ & * a b v g d e = j z i y k l m n o p r s t u f h c x 1 2 3 4 5 6 7 8/;
      @rmap = qw/А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я/; }
        What's that between "@" and "$" in @kmap?

Log In?
Username:
Password:

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

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

    No recent polls found