
Process a String
processString.RdProcesses a given input string by applying optional trimming, case conversion, and ASCII transliteration.
Arguments
- input
A
std::stringrepresenting the input string to be processed.- processor
A
boolindicating whether to trim whitespace and convert the string to lowercase. Default istrue.- asciify
A
boolindicating whether to transliterate non-ASCII characters to their closest ASCII equivalents. Default isfalse.
Details
The function applies the following transformations to the input string, in this order:
Trimming (if
processor = TRUE): Removes leading and trailing whitespace.Lowercasing (if
processor = TRUE): Converts all characters to lowercase.ASCII Transliteration (if
asciify = TRUE): Replaces accented or special characters with their closest ASCII equivalents.
Examples
# Example usage
processString(" Éxâmple! ", processor = TRUE, asciify = TRUE)
#> [1] "example!"
# Returns: "example!"
processString(" Éxâmple! ", processor = TRUE, asciify = FALSE)
#> [1] "éxâmple!"
# Returns: "éxâmple!"
processString(" Éxâmple! ", processor = FALSE, asciify = TRUE)
#> [1] " Example! "
# Returns: "Éxâmple!"
processString(" Éxâmple! ", processor = FALSE, asciify = FALSE)
#> [1] " Éxâmple! "
# Returns: " Éxâmple! "