Skip to content

Instantly share code, notes, and snippets.

@ainvyu
Created May 13, 2011 16:49
Show Gist options
  • Save ainvyu/970866 to your computer and use it in GitHub Desktop.
Save ainvyu/970866 to your computer and use it in GitHub Desktop.
Encoding to utf8
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use File::Slurp;
use Encode;
for my $file (<*.cpp>) {
my $data = read_file($file);
# Already UTF-8
next if utf8::is_utf8($data);
# else assume ANSI code page
$data = "\xEF\xBB\xBF".encode("utf-8", decode("cp949", $data));
write_file($file, {binmode => ':utf8'}, $data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment