Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Data::Dumperで出力したやつの文字列を無理やり変換する
$ perl -MData::Dumper -e 'use utf8; local $Data::Dumper::Purity = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Deepcopy = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; print Dumper { "あ" => "い", "う" => "え" };'
{
  "\x{3042}" => "\x{3044}",
  "\x{3046}" => "\x{3048}"
}
$ perl -MData::Dumper -e 'use utf8; local $Data::Dumper::Purity = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Deepcopy = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; print Dumper { "あ" => "い", "う" => "え" };' | perl -e 'use Encode; while(<>){ $_ =~ s/\\x\{(....)\}/encode_utf8(chr eval "0x$1")/eg; print}'
{
  "" => "",
  "" => ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.