John Smith
John Smith

Reputation: 1698

How to convert special characters into unicode in R?

When doing some textual data cleaning in R, I can found some special characters. In order to get rid of them, I have to know their unicodes, for example € is \u20AC. I would like to know if it is possible "see" the unicodes with a function that take into account the string within the special character as an input?

Upvotes: 2

Views: 4507

Answers (2)

user8378245
user8378245

Reputation:

Refering to Cath comment, iconv can do the job :

iconv("é", toRaw = TRUE)

Then, you may want to unlist and paste with \u00.

Upvotes: 1

Felix Dietrich
Felix Dietrich

Reputation: 127

special_char <- "%"
Unicode::as.u_char(utf8ToInt(special_char))

Upvotes: 1

Related Questions