絵文字変換マップ作成スクリプト

各種JSONファイルは、pictogram-1.1.tar.gz http://blog.asial.co.jp/330 を利用する。

 #!/usr/bin/perl
 
 use strict;
 use utf8;
 use Encode qw/encode decode/;
 use JSON;
 use Jcode;
 use Data::Dumper;
 
 my %files = (
 docomo   => 'docomo_emoji.json',
 convert  => 'docomo_convert.json',
 softbank => 'softbank_emoji.json',
 au       => 'ezweb_emoji.json',
 );
 
 unless (-e $files{docomo} && -e $files{convert} && -e $files{softbank} && -e $files{au}) {
     die "can't find source files\n";
 }
 
 my %json;
 foreach my $k (qw/docomo convert softbank au/) {
     open my $fh, $files{$k} or die $!;
     $json{$k} = do {local $/;<$fh>};
     close $fh;
 }
 
 my %perl;
 foreach my $k (qw/docomo convert softbank au/) {
     $perl{$k} = JSON->new->decode($json{$k});
 }
 
 my %result;
 foreach my $docomo_number ( keys %{ $perl{docomo}->{docomo} } ) {
     my $docomo_sjis10    = $perl{docomo}->{docomo}->{$docomo_number}->{'sjis-10'};
     my $docomo_unicode   = $perl{docomo}->{docomo}->{$docomo_number}->{'unicode'};
     my $softbank_number  = $perl{convert}->{docomo}->{$docomo_number}->{softbank};
     my $softbank_sjis    = $perl{softbank}->{softbank}->{$softbank_number}->{sjis};
     my $softbank_unicode = $perl{softbank}->{softbank}->{$softbank_number}->{unicode};
     my $au_number        = $perl{convert}->{docomo}->{$docomo_number}->{ezweb};
     my $au_unicode       = $perl{au}->{ezweb}->{$au_number}->{unicode};
     $result{$docomo_unicode} = {
         'number'   => $docomo_number,
         'title'    => encode( 'utf-8', $perl{docomo}->{docomo}->{$docomo_number}->{title} ),
         'color'    => encode( 'utf-8', $perl{docomo}->{docomo}->{$docomo_number}->{color} ),
         'docomo'   => $docomo_unicode,
         'softbank' => $softbank_unicode ? $softbank_unicode : 'X',
         'au'       => $au_unicode ? $au_unicode : 'X',
     };
 }
 
 foreach my $k (keys %result) {
     my $buf = sprintf "'&#x%s;'=>array('number'=>%d,'title'=>'%s','color'=>'%s','docomo'=>'&#x%s;','au'=>'&#x%s;','softbank'=>'&#x%s;'),",
         $k,
         $result{$k}->{number},
         $result{$k}->{title},
         $result{$k}->{color},
         $k,
         $result{$k}->{au},
         $result{$k}->{softbank};
     print Jcode->new($buf)->utf8,"\n";
 }

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS