nix, shell, perl, php, mysql and mac os x tips and tricks

Friday, November 3, 2017

search and replace unicode characters for ASCII output in perl

I don't know why you would EVER need this :P but just in case, this handles most of the open/close quote and double quote issues that arise when you need to output to ASCII
 $string =~ s/[\x{00E2}|\x{00C3}|\x{00C2}]?[\x{0080}|\x{0082}|\x{0083}|\x{0000}]?[\x{0099}|\x{00BA}|\x{00B9}|\x{0098}]/'/ig;
 $string =~ s/[\x{00E2}|\x{00C3}|\x{00C2}]?[\x{0080}|\x{0082}|\x{0083}|\x{0000}]?[\x{009C}|\x{009D}|\x{0093}|\x{0094}]/"/ig;
 $string =~ s/\x{2018}/'/ig;
 $string =~ s/\x{201A}/'/ig;
 $string =~ s/\x{2019}/'/ig;
 $string =~ s/\x{2039}/'/ig;
 $string =~ s/\x{203A}/'/ig; 
 $string =~ s/\x{0092}/'/ig; 
 
 $string =~ s/\x{0093}/"/ig;
 $string =~ s/\x{0094}/"/ig;
 $string =~ s/\x{201C}/"/ig;
 $string =~ s/\x{201D}/"/ig;
 $string =~ s/\x{201E}/"/ig;

1 comment:

  1. The online playing business is one of constant innovation and ... Your sport instructions are very detailed, truly have} performed and located 온라인카지노 it very interesting. The face cards which include the Kings, Queens, and Jacks all haven't any value. Ace cards are categorised as low which suggests they're only worth 1 level. ✔ Option to vary deck depend, deck penetration and commission of the desk.

    ReplyDelete