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

Re: Global substitution of non-base-plane Unicode characters

by Jim (Curate)
on Feb 24, 2014 at 00:23 UTC ( [id://1075914]=note: print w/replies, xml ) Need Help??


in reply to Global substitution of non-base-plane Unicode characters

GNU Awk (gawk) isn't really Unicode-capable. Perl is. Using a2p in this case is just causing you needless confusion, especially if your objective is to learn how to handle Unicode using Perl. Your Unicode text substitution is trivially accomplished in Perl 5.18, which is the version you said you're using.

use strict; use warnings; use v5.16; binmode STDOUT, ':encoding(UTF-8)'; printf "\N{U+FEFF}"; # Unicode byte order mark my $text = "Unicode code point U+100049: \N{U+100049}\n"; print $text; $text =~ s/100049/002190/; $text =~ s/\N{U+100049}/\N{U+002190}/; print $text; exit 0; __END__
Unicode code point U+100049:  􀁉
Unicode code point U+002190:  ←

Replies are listed 'Best First'.
Re^2: Global substitution of non-base-plane Unicode characters
by pjfarley3 (Initiate) on Feb 24, 2014 at 04:31 UTC

    I have tried exactly that and it works just fine. Thank you very much!

    And I tested this version and it also works:

    $txline = $_; $ch1 = "\N{U+100049}"; $ch2 = "\N{u+2190}"; $txline =~ s/$ch1/$ch2/g;

    Again many thanks, this helps my understanding a lot.

    Peter

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found