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". >
Close: > as.hexmode(utf8ToInt("£")) [1] "a3" > 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". > intToUtf8(as.hexmode('00A3')) [1] "£" > 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? > > Thanks. > > cheers, > > Rolf Turner > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.