Created
November 8, 2011 10:39
-
-
Save keiya/1347467 to your computer and use it in GitHub Desktop.
Unicode Normalization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Encode; | |
| use Unicode::Normalize qw/NFD NFC/; | |
| my $encoding = $ENV{LANG} =~ /euc-?jp/i ? 'euc-jp' : 'utf-8'; | |
| binmode STDOUT, ":encoding($encoding)"; | |
| binmode STDERR, ":encoding($encoding)"; | |
| while(<STDIN>) { | |
| chomp; | |
| my $nfd = Encode::decode('utf8', $_); | |
| my $nfc = NFC($nfd); | |
| print "renaming $_ to $nfc"; | |
| rename $_,$nfc; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment