[ create a new paste ] login | about

Link: http://codepad.org/iJE0QGoG    [ raw code | output | fork ]

Perl, pasted on Nov 19:
use strict;
use warnings;
use utf8;
use Unicode::Normalize qw/NFKC NFKD NFC NFD/;
binmode STDOUT, ":utf8";

print "$Unicode::Normalize::VERSION\n";

my $src = "あアア がガガ ぱパパ むムム゙ abcabc 123123 ①②Ⅲⅳ";

print NFKC($src) . "\n";
repr(NFKC($src)); print "\n";
print NFKD($src) . "\n";
repr(NFKD($src)); print "\n";
print NFC($src) . "\n";
repr(NFC($src)); print "\n";
print NFD($src) . "\n";
repr(NFD($src)); print "\n";

sub repr {
  my $str = shift;
  for(0..length($str)-1) {
    printf("\\u%04X", unpack("U", substr($str, $_, 1)) );
  }
}


Output:
1
2
3
4
5
6
7
8
9
0.17
あアア がガガ ぱパパ むムム゙ abcabc 123123 12IIIiv
\u3042\u30A2\u30A2\u0020\u304C\u30AC\u30AC\u0020\u3071\u30D1\u30D1\u0020\u3080\u30E0\u30E0\u3099\u0020\u0061\u0062\u0063\u0061\u0062\u0063\u0020\u0031\u0032\u0033\u0031\u0032\u0033\u0020\u0031\u0032\u0049\u0049\u0049\u0069\u0076
あアア がガガ ぱパパ むムム゙ abcabc 123123 12IIIiv
\u3042\u30A2\u30A2\u0020\u304B\u3099\u30AB\u3099\u30AB\u3099\u0020\u306F\u309A\u30CF\u309A\u30CF\u309A\u0020\u3080\u30E0\u30E0\u3099\u0020\u0061\u0062\u0063\u0061\u0062\u0063\u0020\u0031\u0032\u0033\u0031\u0032\u0033\u0020\u0031\u0032\u0049\u0049\u0049\u0069\u0076
あアア がガガ ぱパパ むムム゙ abcabc 123123 ①②Ⅲⅳ
\u3042\u30A2\uFF71\u3000\u304C\u30AC\uFF76\uFF9E\u3000\u3071\u30D1\uFF8A\uFF9F\u3000\u3080\u30E0\uFF91\uFF9E\u3000\u0061\u0062\u0063\uFF41\uFF42\uFF43\u3000\u0031\u0032\u0033\uFF11\uFF12\uFF13\u3000\u2460\u2461\u2162\u2173
あアア がガガ ぱパパ むムム゙ abcabc 123123 ①②Ⅲⅳ
\u3042\u30A2\uFF71\u3000\u304B\u3099\u30AB\u3099\uFF76\uFF9E\u3000\u306F\u309A\u30CF\u309A\uFF8A\uFF9F\u3000\u3080\u30E0\uFF91\uFF9E\u3000\u0061\u0062\u0063\uFF41\uFF42\uFF43\u3000\u0031\u0032\u0033\uFF11\uFF12\uFF13\u3000\u2460\u2461\u2162\u2173


Create a new paste based on this one


Comments: