Assigning Arabic Text to R Variables

R does not display Arabic text correctly. I get very strange things when I use Arabic. Here is a screenshot:

enter image description here

The problem is that I want to create a wordcloud with Arabic text, and first I need to solve this problem.

R version: R 2.15.2 GUI 1.53 Leopard build 64-bit (6335)

More details:

> options("encoding") $encoding [1] "native.enc" > Encoding("الله") [1] "unknown" 

SessionInfo ():

 > sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] C/C/C/C/de_DE/C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.15.2 > 

Some processing:

 > x = "مرحبا" > Encoding(x) = "UTF-8" > x [1] "<U+0645><U+0631><U+062D><U+0628><U+0627>" > Encoding(iconv(x)) [1] "unknown" 

Additional Information:

 > Sys.getlocale() [1] "C/C/C/C/de_DE/C" > Sys.setlocale("LC_ALL", "en_US.utf8") [1] "" Warning message: In Sys.setlocale("LC_ALL", "en_US.utf8") : OS reports request to set locale to "en_US.utf8" cannot be honored > 

This solved the problem:

 Sys.setlocale("LC_ALL", "en_US.UTF-8") 
+6
source share
2 answers

It works:

 Sys.setlocale("LC_ALL", "en_US.UTF-8") 
+2
source

I just wanted to indicate that I do not have this problem (Arabic characters are displayed correctly, without any changes in the locale), although I am not in the UTF-8 locale. Not sure what to do with this, so if anyone else, please enlighten us.

I am using RStudio 0.98.1091, and my sessionInfo looks like this:

 > sessionInfo() R version 3.1.2 (2014-10-31) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 [4] LC_NUMERIC=C LC_TIME=French_France.1252 
0
source

Source: https://habr.com/ru/post/953401/