简体   繁体   中英

Control character encoding in the 'rio' package?

My txt table looks like this:

morče   kanár   malý pes
morče   potkan  rybičky
želva   rybičky střední pes
kočka   papoušek    želva

It is encoded in UTF-8 and stored in file mazlicci.txt . When I try

library(rio)
import("mazlicci.txt")

the character encoding is broken.

How can I control character encoding in the rio package? The encoding argument in import knows only three charsets: UTF-8 , unknown , and Latin-1 . The UTF-8 option does not remedy the problem. (Nor the other ones, expectedly.) I am working on Windows 7, R version 3.2.4 (2016-03-10) -- "Very Secure Dishes", Platform: i386-w64-mingw32/i386 (32-bit) ,Czech locale (cp1250). I experience no encoding problems with UTF-8 encoded files using the basic R importing functions.

You can specify the encoding in the import function:

library(rio)
import("mazlicci.txt", encoding = "UTF-8")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM