DescTools (version 0.99.14)

AscToChar: Convert ASCII Codes to Characters and Vice Versa

Description

AscToChar returns a character for each ASCII code (integer) supplied. CharToAsc returns integer codes in 0:255 for each (one byte) character in strings.

Usage

AscToChar(i)
CharToAsc(x)

Arguments

i
numeric (integer) vector of values in 1:255.
x
character vector.

Value

  • AscToChar and CharToAsc return a vector of the same length as their argument.

Details

Only codes in 1:127 make up the ASCII encoding which should be identical for all Rversions, whereas the upper half is often determined from the ISO-8859-1 (aka ISO-Latin 1) encoding, but may well differ, depending on the locale setting, see also Sys.setlocale. Note that 0 is no longer allowed since, Rdoes not allow \0 aka nul characters in a string anymore.

Examples

Run this code
(x <- CharToAsc("Silvia"))
paste(AscToChar(x), collapse="")

Run the code above in your browser using DataCamp Workspace