0

Since I have downloaded the latest version of R (ARM) and Rstudio using homebrew, locales do not properly work on either Rstudio or MacOS terminal.

I did make sure to set the locales properly:

> system("locale")
LANG="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_CTYPE="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_ALL=

> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] ja_JP.UTF-8/ja_JP.UTF-8/ja_JP.UTF-8/C/ja_JP.UTF-8/ja_JP.UTF-8

However, the letters that I tried to show on the screen do not appear in a way that it should be.

> print("日本") 
[1] "\u65e5\u672c"

The letters I want to get are Japanese but the output (mix of letters and numbers) seems to be unicode. Note that R and Rstudio worked properly before R was replaced by the ARM version, and the explanation of R which first appears on the screen works well in the language I set.

Hitomi
  • 1
  • 1
  • Use `cat()` insetad of `print()`. Even 'cat("\u65e5\u672c")' will result in 日本 – kukuk1de Feb 26 '21 at 16:35
  • Please see also https://stackoverflow.com/questions/31843662/what-is-the-difference-between-cat-and-print – kukuk1de Feb 26 '21 at 16:37
  • `cat()` itself works (`cat("日本")` results in 日本), but `cat("\u65e5\u672c")` also returns 日本. – Hitomi Feb 26 '21 at 23:04
  • I just found someone has the same issue, locales are different though. Is this because of the R version 4? @Eureka, did you solve the problem? [Output problem with Chinese characters in r console, r version 4](https://stackoverflow.com/questions/66341119/output-problem-with-chinese-characters-in-r-console-r-version-4) – Hitomi Feb 27 '21 at 12:31

0 Answers0