Skip to content

Instantly share code, notes, and snippets.

@jmclawson
Created March 31, 2026 14:48
Show Gist options
  • Select an option

  • Save jmclawson/e507ef52a787d298e6de2980953cb1b2 to your computer and use it in GitHub Desktop.

Select an option

Save jmclawson/e507ef52a787d298e6de2980953cb1b2 to your computer and use it in GitHub Desktop.
# Convert UTF-8 characters to other encodings:
## A special character (e.g., in an Excel file)
## might mess up later steps, so we may want to
## use Unicode or ASCII encodings.
## Example:
### ≥ depicted as ">=" or "U+2265"
my_string <- "Check whether x ≥ 4"
my_string |>
iconv(to = "ASCII//TRANSLIT")
# [1] "Check whether x >= 4"
my_string |>
iconv(to = "ASCII",
sub = "Unicode")
# [1] "Check whether x <U+2265> 4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment