Encoding in R like Python ("ord" and "chr") -
i wondering how encoding , decoding in r. in python, can use ord('a') , chr(97) transform letter number or transform number letter. know similar functions in r? thank you!
for example, in python
>>>ord("a")
97
>>>ord("a")
65
>>>chr(97)
'a'
>>>chr(90)
'z'
fyi: ord(c) in python given string of length one, return integer representing unicode code point of character when argument unicode object, or value of byte when argument 8-bit string. example, ord('a') returns integer 97, ord(u'\u2020') returns 8224. inverse of chr() 8-bit strings , of unichr() unicode objects. if unicode argument given , python built ucs2 unicode, character’s code point must in range [0..65535] inclusive; otherwise string length two, , typeerror raised.
chr(i) in python return string of 1 character ascii code integer i. example, chr(97) returns string 'a'. inverse of ord(). argument must in range [0..255], inclusive; valueerror raised if outside range. see unichr().
you're looking utf8toint
, inttoutf8
utf8toint("a") [1] 97 inttoutf8(97) [1] "a"
Comments
Post a Comment