Do you knwo, if there's an equivalent to the JavaScript function fromCharCode? It converts Unicode values into characters.
Asked
Active
Viewed 136 times
1 Answers
1
There is a function called rawToChar
in R as described here which do the required trick.
> rawToChar(as.raw(65))
[1] "A"

parth
- 1,571
- 15
- 24
-
as.raw() unfortunately is out of range when I insert large Unicode numbers like 55357 (maximum is 255) – Stezi Jul 21 '17 at 12:03
-
Do you know a function that does the job or have an idea where to look for it? Best regards – Stezi Jul 24 '17 at 21:43
-
one workaround i came up with is [this](https://cran.r-project.org/web/packages/V8/vignettes/v8_intro.html) but `R` can't convert it to print in console – parth Jul 25 '17 at 12:34
-
-
Yes, using `sink` it can be done but `R` doesn't seems to print `js` output in console ! – parth Jul 26 '17 at 05:20
-
So it seems like intToUtf8(56881) does the same as ct$eval(paste0('String.fromCharCode(',acc,')')). – Stezi Jul 26 '17 at 08:44
-
But when I write() the numbers 55357 and 56881 to a text file using UTF-16 encoding, it becomes xEDxA0xBDxEDxB8. When I copy this from Notepad++ to the browser, it becomes (and copying back to the file preserves the emoji). Any idea how to save this directly as ? – Stezi Jul 26 '17 at 08:51