我有一個 Rscript,當我在 RStudio 中執行它時,它執行得很好。如果我通過批處理檔案執行相同的 Rscript,它無法處理德語“Umlaute”(?、?、ü)。
- RScript 保存為 UTF-8
- 默認文本編碼設定為 UTF-8
- 我嘗試將CHCP 65001和chcp 1252添加到批處理檔案中,結果相同,如下所示:
CHCP 65001
"C:/Users/John Doe/Documents/R/R-4.0.5/bin/Rscript.exe" "uebel.R"
pause
是批處理有問題嗎?我能做些什么來避免它?
在我的情況下,僅洗掉所有“Umlaute”是行不通的。從技術上講,它會,但實際上并非如此。
非常簡單的例子:
RScript,另存為“uebel.R”:
übel <- 1 1
批處理檔案,另存為:“uebel.bat”:
"C:/Users/John Doe/Documents/R/R-4.0.5/bin/Rscript.exe" "uebel.R"
pause
在 cmd 中給我錯誤:
Fehler: unerwartete Eingabe in "??" (Error: unexpected input in "??")
Rscript 中的另一個示例以及我在 cmd 中收到的內容:
cat("übelkeit")
??belkeit
uj5u.com熱心網友回復:
嘗試打電話
"C:/Users/John Doe/Documents/R/R-4.0.5/bin/Rscript.exe" --encoding="UTF-8" "uebel.R"
uj5u.com熱心網友回復:
還有一個使用包“ds4psy”來列印變音符號的解決方案:
一個例子:
library(ds4psy)
cat (Umlaut["U"],"belkeit", sep = "")
übelkeit
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/337929.html
上一篇:在sqlbolt上學習SQL
下一篇:根據總大小批量移動檔案
