in reply to Handling special characters in JSON
Is there an existing perl module that will convert special characters into the \uXXXX form?
You could do something like this:
my $s = "téxt"; $s =~ s/([^\x20-\x7e])/sprintf '\u%04x', ord($1)/ge; print $s; # t\u00e9xt
This will convert everything outside of the printable ASCII range to \uXXXX notation.
You might need to decode your input strings into Perl's internal Unicode representation, depending on which encoding they're originally in.
|
|---|