How to read and output Hindi in the R console?

I am trying to read and output a Hindi .txt file to the R console, but I am getting gibberish. This is what I have done so far.

hindi <- read.table('hindi_text.txt')
hindi

1 कà¥à¤¯à¤¾ बोल रहे हो तà¥à¤®

      

Then I typed this. It still doesn't work.

> Sys.setlocale(category="LC_ALL", locale="hindi")
> [1] "LC_COLLATE=Hindi_India.1252;LC_CTYPE=Hindi_India.1252;LC_MONETARY=Hindi_India.1252;LC_NUMERIC=C;LC_TIME=Hindi_India.1252"
> hindi
> 1 कà¥à¤¯à¤¾ बोल रहे हो तà¥à¤®

      

I tried this by reading Chinese characters, changing the locale to Chinese and it worked.

> chinese <- read.table("chinese.txt")
> Sys.setlocale(category="LC_ALL", locale="chinese")
> [1] "LC_COLLATE=Chinese (Simplified)_China.936;LC_CTYPE=Chinese (Simplified)_China.936;LC_MONETARY=Chinese (Simplified)_China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_China.936"
> chinese
> 1 锘夸负浠€涔堣繖涓敞鎰忥紝杩欎釜宸ヤ綔

      

Why does this work with Chinese and not Hindi (and some other languages), and is there a way to make it work?

+3


source to share





All Articles