[R] Obtain the hex code for a given character.
dwinsemius at comcast.net
Wed Feb 5 05:56:20 CET 2014
On Feb 4, 2014, at 4:57 PM, Rolf Turner wrote:
> If I have a character such as "£" stored in a object called "xxx", how can I obtain the hex code representation of this character? In this case I know that the hex code is "\u00A3", but if I didn't, how would I find out?
> I would like a function "foo()" such that foo(xxx) would return, say, the string "00A3".
> I have googled and otherwise searched around and have come up with nothing that seemed at all helpful to me. If I am missing something obvious, please point me at it.
> (I have found a table on the web, which contains the information that I need, but it is only accessible "by eye" as far as I can discern.)
> Supplementary question: Suppose I have the string "00A3" stored in
> an object called "yyy".
> How do I put that string together with "\u"
> so as to obtain "£"? I thought I could do
> xxx <- paste("\u",yyy,sep="")
> but R won't let me use "\u" "without hex digits". How can I get around this?
> Rolf Turner
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Alameda, CA, USA
More information about the R-help