Q:

Special characters to UTF-8 byte in r

I am working with a vector of text, which contains odd characters such as:
í, ã, ú etc.
I am working with an api to translate them from Portuguese to English, but the problem is that the encoding of the API prefers it to be UTF-8 hex encoded. This means that the text that I send through needs to be as follow:
Província: Prov%C3%ADncia

I can use iconv in R, in the follow manner:
iconv("Província", "UTF-8", sub = "byte")
[1] "Prov<ed>ncia"

But it provides a different result. Is there a way in R to do this?

A:

To read special characters you need : 
x <- enc2utf8(as("Província", "character"))
y <- iconv("Província", "LATIN2", "UTF-8")
[1] "Província"

Encoding(x) <- "bytes"
Encoding(y) <- "bytes"
cat(y,"\n");cat(x)

> Prov\xc3\xadncia 
> Prov\xc3\xadncia

