in reply to malformed UTF-8 character in JSON string in perl

Is [there] any module other than Text::Unidecode, or a method of converting these characters like ',",-,.,? to simple ASCII characters?
Why do you not want to use Text::Unidecode? It does exactly what you are requesting:
use utf8; use JSON; use Encode qw(encode_utf8); use Text::Unidecode; my $data = qq( { "cat" : "text – abcd “ ’ ” ‘" } ); my $json_data = encode_utf8( $data ); my $perl_hash = decode_json( $json_data ); while ( my($k,$v) = each %$perl_hash ) { unidecode($v); print "$k => $v\n"; }
Output:
cat => text - abcd " ' " '

Replies are listed 'Best First'.
Re^2: malformed UTF-8 character in JSON string in perl
by Yllar (Novice) on Aug 11, 2015 at 15:19 UTC

    Hi Tangent

    In below statements which statement did you use in your code?

    1) "text - abcd “

    2) "text – abcd “

    would you please try with the second statement and see what output you are getting?

      I used the second one. It might be easier to use the names - in the following I input plain dash "-", en dash "–" and em dash "—" and the output is plain dash, plain dash, double plain dash:
      "text - – —" input "text - - --" output

        Hi Tangent

        Would you please use the statements that I mentioned. I mean please copy and paste in your script and try please.

        If you see in the second statement "-" is not a general hyphen or dash. It is a special symbol.