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

Re: Regexp \N{name}

by cjb (Friar)
on Feb 03, 2011 at 10:38 UTC ( #885960=note: print w/replies, xml ) Need Help??

in reply to Re: Regexp \N{name} (use of \e)

#!/opt/perl/bin/perl use strict; use warnings; use charnames ':full'; binmode STDOUT, ":utf8"; my $string = ':)'; print "$string becomes: "; $string =~ s/:\)/\N{WHITE SMILING FACE}/; print "$string\n$string becomes: "; $string =~ s/\N{WHITE SMILING FACE}/\N{BLACK SMILING FACE}/; print "$string\n$string becomes: "; $string =~s/\N{BLACK SMILING FACE}/:\)/; print "$string\n";

That should cover most uses of \N{CHARNAME}.

charnames and perlre are the best references.

Update: added #! to example

Replies are listed 'Best First'.
use of \e
by gautam_9jan on Feb 03, 2011 at 19:14 UTC
    Thank you for your reply please can you tell me why you used binmode STDOUT, ":utf8"; please reply me as soon as possible.........
      Check out perlunicode, <STDOUT> is just a file handle so a belts and braces approach to ensure that it was displaying the unicode characters correctly.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://885960]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-12-11 21:53 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (313 votes). Check out past polls.