Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1045

wrong text file output of special characters using UTF-8 enconding in R 3.1.2 with Mac OS X

$
0
0

I am having problems to write a csv file with Spanish accents, using R 3.1.2 and Mac OS X 10.6.

I cannot write words with accents into text file.

When I do:

con <- file("y.csv",encoding="UTF-8")write.csv("Ú",con)

I get y.csv file which has the following content:

"","x""1","√ö"

Ie, "√ö" instead of "Ú".

When using write.table the outcome is equivalent.

Encoding("Ú") is "UTF-8"

If I do write.xlsx("Ú","y.xlsx") I get y.xlsx file which successfully shows Ú.

I have also tried to convert to other encodings using iconv() with no success.

I have set default encoding "UTF-8" in RStudio and on TextEdit. When using only R (not RStudio) the problem is the same.In RStudio the special characters appear correctly (in files), and also in the console in R.

Sys.getlocale()gives

"es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8"

In Mac OS X Terminal

file -I y.csv

gives

y.csv: text/plain; charset=utf-8

I don't see where the problem is. Any help, please?


Viewing all articles
Browse latest Browse all 1045

Trending Articles