Skip to content

Instantly share code, notes, and snippets.

@ifduyue
Created March 17, 2017 09:42
Show Gist options
  • Save ifduyue/6b54446196e1bedf45ea33d82eba46f7 to your computer and use it in GitHub Desktop.
Save ifduyue/6b54446196e1bedf45ea33d82eba46f7 to your computer and use it in GitHub Desktop.
Confused with perl5 utf8 json
"苦" 34:33510:34
"苦" 34:232:139:166:34
Wide character in say at -e line 1.
"苦" 34:33510:34
"苦" 34:232:139:166:34
"苦" 34:232:139:166:34
"苦" 34:195:168:194:139:194:166:34
"苦" 34:232:139:166:34
"苦" 34:195:168:194:139:194:166:34
#!/bin/bash
perl -Mfeature=say -MJSON -Mutf8 -CS -e 'my $json = JSON->new->allow_nonref ->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -Mutf8 -CS -e 'my $json = JSON->new->allow_nonref->utf8->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -Mutf8 -e 'my $json = JSON->new->allow_nonref ->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -Mutf8 -e 'my $json = JSON->new->allow_nonref->utf8->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -e 'my $json = JSON->new->allow_nonref ->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -e 'my $json = JSON->new->allow_nonref->utf8->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -CS -e 'my $json = JSON->new->allow_nonref ->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
perl -Mfeature=say -MJSON -CS -e 'my $json = JSON->new->allow_nonref->utf8->encode("苦"); say $json, "\t", join ":", map { ord } split //, $json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment