Преобразование в число и обратно

Простые типы / Символьный тип

# No char type: a char is a string of length 1
char <- "A"

# Code point of the char
int_value <- utf8ToInt(char)
# int_value = 65

char_b <- intToUtf8(int_value + 1)
# char_b = B

# Any Unicode char, not only ASCII
euro_value <- utf8ToInt("€")
# euro_value = 8364

# A longer string gives a code per char
codes <- utf8ToInt("ABC")
# codes = 65 66 67

# The codes make one string back
word <- intToUtf8(codes)
# word = ABC

cat("int_value =", int_value, "\n")
cat("char_b =", char_b, "\n")
cat("euro_value =", euro_value, "\n")
cat("codes =", codes, "\n")
cat("word =", word, "\n")