Skip to content

Instantly share code, notes, and snippets.

@mix3
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mix3/27f0e7f593aacd9787e7 to your computer and use it in GitHub Desktop.
Save mix3/27f0e7f593aacd9787e7 to your computer and use it in GitHub Desktop.
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