[Omaha.pm] s/[^ -~]//g; strikes again

Jay Hannah jhannah at omnihotels.com
Mon Feb 26 10:39:24 PST 2007


Yet again this morning a program was choking on "binary characters",
this time in a Spanish address field that our XML library doesn't handle
gracefully by default. 

Once again instead of actually making a system smart enough to handle
Unicode I opted instead to just whack any characters that aren't in
SPACE (" ") through TILDE ("~") in the ASCII chart.

$conv_xml =~ s/[^ -~]//g;

Works like a dream. I live in the rural midwest, USA; why would I care
about anything not in that range in the good-ole' ASCII table? :)

Just curious: Does anyone on the list explicitly process Unicode w/
Perl? I think we've had some stuff that just magically works without us
understanding it, but it's 2007 and I still have never explicitly
handled such things. :)

j
lives a sheltered life



More information about the Omaha-pm mailing list