Skip to content

Instantly share code, notes, and snippets.

@sgibb
Created September 9, 2013 17:11
Show Gist options
  • Save sgibb/6498636 to your computer and use it in GitHub Desktop.
Save sgibb/6498636 to your computer and use it in GitHub Desktop.
convert a file from one encoding to another one
convertFile <- function(inputFile, outputFile,
fromEncoding="UTF-8", toEncoding="ASCII") {
stopifnot(file.exists(inputFile))
input <- readLines(inputFile, encoding=fromEncoding)
output <- iconv(input, from=fromEncoding, to=toEncoding)
return(writeLines(output, outputFile))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment