swarm-lab / editR

A Rmarkdown editor with instant preview
GNU General Public License v3.0
350 stars 30 forks source link

cannot open file with unicode characters correctly #22

Open dracodoc opened 7 years ago

dracodoc commented 7 years ago
  1. For file with only English characters but encoded in GB2312 or UTF-8 without signature, it can be opened correctly.
  2. For file encoded with UTF-8 with signature, there is some messed up code in file beginning:

锘<bf>--- title: "Untitled"

  1. For file with Unicode characters and encoded in UTF-8 (I didn't see any special characters visually, but converting the file to non-Unicode encoding will have the warning of loss of characters), editR will open an empty window.
  2. If I convert the above file to GB2312 (there is no Chinese characters inside it) and proceed with the warning of loss of some Unicode characters, it can be opened by editR correctly.

There is always this warning in console, no matter if the file was read correctly:

Warning in readChar(md_name, file.info(md_name)$size) : can only read in bytes in a non-UTF-8 MBCS locale

My sessioninfo:

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936    LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C                               LC_TIME=Chinese (Simplified)_China.936