Skip to contents

Unicode includes several control codes, such as U+0000 (NULL, used in null-terminated strings) and U+000D (carriage return). This function removes all such characters from text.

Usage

remove_control_characters(text)

Arguments

text

A character vector to clean.

Value

The character vector without control characters.

Details

Note: We highly recommend that you first condense all space-like characters (including new lines) before removing control codes. You can easily do so with str_squish. We also recommend validating text at the start of any cleaning process using validate_utf8.

Examples

remove_control_characters("Line 1\nLine2")
#> [1] "Line 1Line2"