Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regexp to convert high-bit (?) characters to character entites

by epoptai (Curate)
on Jul 10, 2002 at 04:51 UTC ( #180676=note: print w/replies, xml ) Need Help??


in reply to Regexp to convert high-bit (?) characters to character entites

Here's a useful little sub from XML::TiePYX that mirod turned me on to:

sub encode { my($text) = @_; $text =~ s{([\xc0-\xc3])(.)}{ my $hi = ord($1); my $lo = ord($2); chr((($hi & 0x03) <<6) | ($lo & 0x3F)) }ge; return $text; }

--
Check out my Perlmonks Related Scripts like framechat, reputer, and xNN.

  • Comment on Re: Regexp to convert high-bit (?) characters to character entites
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://180676]
help
Chatterbox?
[perldigious]: I watched some video on YT awhile back with auto-subtitle on and the speaker had a very thick cockney sort of English accent... hillarity ensued in the subtitles.
[Discipulus]: IHAA=I hate acronyms anyway
LanX LOLs
[perldigious]: If you want a linguistic adventure...
[perldigious]: No offense to any Scotsman, I love Scots. Well actually, I love Scotch, but I'm sure the people are great too. :-P
[Discipulus]: perldigious i understand i word on ten, to be optimistic..
LanX will try to give his next LPW talk with a Cogney intonation
[Discipulus]: if you love Scotch in scotland your safety will be.. glengranted

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2017-06-23 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (552 votes). Check out past polls.