HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
161 stars 5 forks source link

My Rprofile has encoding issues #132

Open Diego-MX opened 4 months ago

Diego-MX commented 4 months ago

I have created a function that I use all the time:

str_delatinize <- function (x) chartr("ÁÉÍÓÚÑáéíóúñ", "AEIOUNaeioun", x)

The issue with this function is the latin characters that are not encoded correctly when sourced via different channels. From what I read this issue is more present in Windows than other systems, but I can't verify it.

When sourced incorrectly this function shows the following error:

Error in chartr("Ã\201ÉÃ\215ÓÚÑáéíóúñ", "AEIOUNaeioun", x) :
  'old' is longer than 'new'

All the latin characters are encoded weirdly, and actually this is the reason to delatinize them.

When sourcing this directly, I can pass an encoding parameter like so:

source("file_with_function.R", encoding="utf-8")

Is there a way to pass encoding parameter when calling startup::startup()?

Thank you.

HenrikBengtsson commented 2 months ago

I've added argument encoding to startup(), e.g.

startup::startup(encoding = "utf-8")

Could you please try with the version in the develop branch, i.e.

remotes::install_github("HenrikBengtsson/startup", ref = "develop")