Created
May 27, 2014 15:00
-
-
Save nmische/93b8c77455570284afa3 to your computer and use it in GitHub Desktop.
A script to convert files to UTF-8.
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
new File('~/tmp').eachFile { | |
def toolkit = new CharsetToolkit(it) | |
def cs = toolkit.getCharset().toString() | |
def filePath = it.path + '/' + it.name | |
println filePath + ': ' + cs | |
if (cs != 'UTF-8') { | |
def content = it.getText(cs) | |
it.write(content ,'UTF-8') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment