Reputation: 1155
Suppose you have an atomic vector containing encoded character strings:
string_encoding <- c("São Paulo", "Paraná")
Is there any way to decode every element in the vector, returning a vector of the same length with ASCII, ISO-8859-1 or other class of encoding?
The output should be:
expected_encoding <- c("Sao Paulo", "Parana")
Upvotes: 2
Views: 645
Reputation: 39595
Another option can be:
iconv(string_encoding, to='ASCII//TRANSLIT')
Output:
[1] "Sao Paulo" "Parana"
Upvotes: 1
Reputation: 39858
Using stringi
, you can do:
stri_trans_general(string_encoding, "Latin-ASCII")
[1] "Sao Paulo" "Parana"
Upvotes: 2