Change encoding of multiples files at same time

29 views Asked by At
Problem

After updating R to 4.3.2 version, I started to face encoding issues, especially with Quarto type documents. These problems didn't occur before the update.

For some reason that I don't know what is, it seems that these type of files aren't rendering anymore with encoding other than UTF-8 (at least in my machine after the update). The problem is that almost all my files are encoded in ISO-8859-1. So I'm stuck in a situation where even though I can correctly read a file in the source editor, it can't correctly render a markdown-based Quarto document.

What I've leanerd from this journey

I tried to change RStudio default encoding to UTF-8 but it messes up all my files in ISO-8859-1 - for example altering words like 'famílias' to 'fam?lias'. Then I noted that, to change one specific file from ISO-8859-1 to UTF-8, I actually needed to take it and 'Save with encoding' in UTF-8 and then change the default RStudio encoding to UTF-8.

Question

Given this problem, and given that from what I've read it seems like it's not good coding practice to keep files encoded in ISO-8859-1, I feel inclined to change them. So my question is: how can I transfer all my files that are encoded in ISO-8859-1 to UTF-8 without necessarily doing it one by one manually? I apologize in advance for any misconception done!

sessionInfo():

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8  LC_CTYPE=Portuguese_Brazil.utf8   
[3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.utf8    

time zone: America/Sao_Paulo
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.3.2    tools_4.3.2       rstudioapi_0.15.0 Rcpp_1.0.12       stringi_1.8.3    
[6] zip_2.3.0         openxlsx_4.2.5.2 
0

There are 0 answers