About garbled rscript characters

Asked 2 years ago, Updated 2 years ago, 78 views

If you run r.exe or rscript.exe from a Windows 10 command prompt, you will place the following characters:

C:\Program Files\R\R-3.3.2\bin\x64>r

Version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright(C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64(64-bit)

US>Rbe A RRen\tgEFAana Au SSリロVenny B
f ]] ホ A RトzアR zz FlaノオOtobe A'license()'be'licence()'Nibeotsew'B

Rvesuv"Meme, vWFNgnak B
US>Reube 'contributors()'Nibeotsew "B
WSARR pbP[Wonina pqlov`ノツ 「"Tobe
US>'citation()'Nippew"B

US>'demo()'Nibekibo fanェキ B < B
US>'help()'NiNiNiNiNiNiNiNiNiNiNiNiNiNiNiNiNiNiNiNi US>'help.start()'na HTML uEUvwvunk B
US>'q()'Nivebo RI Code B

If you change the command prompt character code to utf-8, it will appear in English, so the first message will contain garbled characters, but if you run a program that contains a Japanese string, it will become garbled.The results of rscript are as follows:

C:\Program Files\R\R-3.3.2\bin\x64>rscript test.r
G[:\cabeswane}`oCg Case(1s)
US>Tasquan~Wasquan

sessionInfo() is as follows:
Version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64(64-bit)
Running under: Windows 10 x64 (build 14393)

locale:
[1] LC_COLATE=Japanese_Japan.932LC_CTYPE=Japanese_Japan.932
[3] LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C
[5] LC_TIME=Japanese_Japan.932

If anyone knows the cause, could you give me some advice?

r garbled-characters

2022-09-30 19:35

1 Answers

First,

 C:\Program Files\R\R-3.3.2\bin\x64>rscript test.r
G[:\cabeswane}`oCg case (1s)
TASK-WASH

The error is

Error: invalid multibyte character in parser at line 1
Execution halted

Error reading script.
To resolve this, suppose the script file is stored in utf-8,

rscript --encoding=utf-8test.r

Specify the appropriate encoding when running the script.

However, in the script, for example,

cat("Hello, world\n")

If you write, this is garbled at the command prompt.
I don't know why.
The way to avoid this is

It's either .

As for the message when starting R, the message should be in English or

>r--quiet

That's how it starts without sending a message.
To put the startup message in English, use the file .Renviron

LANGUAGE=en

Write
and save it to your home directory.
The home directory is R

path.expand("~")

You can find out by running .


2022-09-30 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.