What is my encoding?

Imagine that you have a file but you don't know what is the encoding. Here is a way to determine it:

Let create a file with Excel using the function "Save as" and then choose, Text (separator : tabulation) (.txt)

How to read it ?
> file.name <- "path to the file"

> x <- unlist(lapply(iconvlist(), function(enc) try(read.table(file.name, fileEncoding=enc, nrows=1, header=FALSE, sep="\t"), silent = TRUE)))

If the first cell contains Ebodjé for example:
> z <- lapply(x, function(y) {y=="ebodjé"})

> which(unlist(z))
     CSMACINTOSH              MAC        MACARABIC MACCENTRALEUROPE      MACCROATIAN         MACGREEK 
             126              330              331              332              333              335 
       MACHEBREW       MACICELAND        MACINTOSH         MACROMAN       MACROMANIA       MACTURKISH 
             336              337              338              339              340              342 

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04