Convert character vector to ASCII, replacing non-ASCII characters with single-byte (\x00) or two-byte (\u0000) codes.
ASCIIfy(x, bytes = 2, fallback = "?")A character vector like x, except non-ASCII characters have been
replaced with \x00 or \u0000 codes.
To render single backslashes, use these or similar techniques:
The resulting strings are plain ASCII and can be used in R functions and datasets to improve package portability.
showNonASCII identifies non-ASCII characters in a
character vector.
cities <- c("S\u00e3o Paulo", "Reykjav\u00edk")
print(cities)
#> [1] "São Paulo" "Reykjavík"
ASCIIfy(cities, 1)
#> [1] "S\\xe3o Paulo" "Reykjav\\xedk"
ASCIIfy(cities, 2)
#> [1] "S\\u00e3o Paulo" "Reykjav\\u00edk"
athens <- "\u0391\u03b8\u03ae\u03bd\u03b1"
print(athens)
#> [1] "Αθήνα"
ASCIIfy(athens)
#> [1] "\\u0391\\u03b8\\u03ae\\u03bd\\u03b1"