Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Locale Woes...

by fenLisesi (Priest)
on Jun 04, 2007 at 11:15 UTC ( [id://619095]=note: print w/replies, xml ) Need Help??


in reply to Locale Woes...

Something like the following may help (encode_monk and decode_monk are only there to save you potential character set problems with your text editor -- don't let them distract you). Cheers.
use strict; use warnings; use Encode 'decode_utf8'; my $suspect = decode_utf8( decode_monk('v~C3~A4hicule') ); warn '$suspect='.$suspect; if ($suspect =~ /^([\p{IsAlnum}]+)$/) { warn "MATCHES $1\n"; } exit( 0 ); ##------------------------------------------------------------------+ ## WARNING: Using sprintf here is too expensive. A ## lookup table may be the best solution. sub encode_monk { my ($txt) = @_; join q(), map { ( $_ >= 0x20 && $_ <= 0x7D ) ? ( sprintf "%c", $_ ) : ( sprintf "~%02X", $_ ) } unpack "C*", $txt; } ##------------------------------------------------------------------+ ## WARNING: Consider err policy here. sub decode_monk { my ($code) = @_; if (! defined $code or length( $code ) == 0) { return; } $code =~ s/\~([\da-fA-F]{2})/chr( hex( $1 ) )/eg; return $code; }

Log In?
Username:
Password:

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

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

    No recent polls found