Created
May 13, 2011 16:49
-
-
Save ainvyu/970866 to your computer and use it in GitHub Desktop.
Encoding to utf8
This file contains 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/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