Replace Non-ASCII Characters with Comparable ASCII Characters
Source:R/replace_non_ascii.R
replace_non_ascii.Rd
Finds all non-ASCII (American Standard Code for Information Interchange) characters in a character vector and replaces them with ASCII characters that are as visually similar as possible. For example, various special dash types (e.g., em dash, en dash, etc.) are replaced with a hyphen. The function will return a warning if it finds any non-ASCII characters for which it does not have a hard-coded replacement. Please open a GitHub Issue if you encounter this warning and have a suggestion for what the replacement character should be for that particular character.
Examples
# Make a vector of the hexadecimal codes for several non-ASCII characters
## This function accepts the characters themselves but CRAN checks do not
non_ascii <- c("\u201C", "\u00AC", "\u00D7")
# Invoke function
(ascii <- replace_non_ascii(x = non_ascii))
#> [1] "\"" "-" "x"