Can't use utf-8 variable names in RStudio console

Hi,
I am running Chinese Win10. I have no problem on regular R console (running inside cmd.exe) to use Chinese characters in a variable name:

吴 <- 'abc'

but the same statement running inside RStudio IDE shows:

Error: invalid multibyte character in parser at line 1

the same statement runs fine in a RScript windows inside IDE. so it's purely a problem with console in IDE.. I have confirmed encoding in my project options is UTF-8. I can't find relavent options in Global Options to set console encoding to utf-8

This link may help RStudio can't deal with file names with unicode characters - #3 by Oliver1.

If not can you give us a reprex and your sessionInfo() output?

Hi, yeah, it seems to be a similar problem... the system code page on my Windows is also 65001.

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936    LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    
system code page: 65001

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

other attached packages:
[1] RMySQL_0.10.23 DBI_1.1.2     

loaded via a namespace (and not attached):
 [1] compiler_4.1.2  here_1.0.1      Matrix_1.3-4    rprojroot_2.0.2 tools_4.1.2     rappdirs_0.3.3  Rcpp_1.0.8      reticulate_1.23 grid_4.1.2      jsonlite_1.7.2  png_0.1-7       lattice_0.20-45
> 吴 <- 1
Error: invalid multibyte character in parser at line 1
> wu <- 1
>

see the error above? but exact same code works on my other PC running Windows, and sessionInfo shows identical code page settings. I have no idea what other differences between two PC's

I am not a Windows user so am of no help. It is weird.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.