Skip to content

Instantly share code, notes, and snippets.

@keiya
Created November 8, 2011 10:39
Show Gist options
  • Select an option

  • Save keiya/1347467 to your computer and use it in GitHub Desktop.

Select an option

Save keiya/1347467 to your computer and use it in GitHub Desktop.
Unicode Normalization
#!/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