startup icon indicating copy to clipboard operation
startup copied to clipboard

My Rprofile has encoding issues

Open Ergodic-Commiter opened this issue 1 year ago • 1 comments

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.

Ergodic-Commiter avatar Mar 08 '24 18:03 Ergodic-Commiter

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")

HenrikBengtsson avatar Apr 19 '24 04:04 HenrikBengtsson