noamross / redoc

[NOTE: Project in suspended animation for now] Reversible Reproducible Documents
https://noamross.github.io/redoc
Other
514 stars 44 forks source link

Not compatible with Chinese #58

Open sammo3182 opened 4 years ago

sammo3182 commented 4 years ago

I, as a MS Word user, appreciate this change tracking function from redoc so very much! However, recently, I encountered troubles when writing articles with redoc in Chinese. I attached a demo file based on a simplified version of Yihui's ctex template in rticle. The file can be compiled by word_document but not redoc. test.zip

The error message was

processing file: test.preprocessed.Rmd
Quitting from lines 2-19 (test.preprocessed.Rmd) 
Error in nchar(input) : invalid multibyte string, element 1
Calls: <Anonymous> ... process_group.inline -> call_inline -> in_dir -> inline_exec
In addition: Warning messages:
1: In readChar(x, file.info(x)$size) :
  can only read in bytes in a non-UTF-8 MBCS locale
2: In knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet,  :
  The file "test.preprocessed.Rmd" must be encoded in UTF-8. Please see https://yihui.name/en/2018/11/biggest-regret-knitr/ for more info.
Execution halted

I'm using MS Word 2019 and here's the session info and, yes, I already set the default encoding as UTF-8 and tried to switch Sys.setlocale() to Chinese and English. Nothing helps.

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

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

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3             whoami_1.3.0          
 [3] digest_0.6.23          crayon_1.3.4          
 [5] mime_0.7               R6_2.4.1              
 [7] jsonlite_1.6           magrittr_1.5          
 [9] evaluate_0.14          httr_1.4.1            
[11] zip_2.0.4              stringi_1.4.3         
[13] rlang_0.4.2            uuid_0.1-2            
[15] diffobj_0.2.3          rstudioapi_0.10.0-9003
[17] xml2_1.2.2             rmarkdown_1.18        
[19] tools_3.6.1            officer_0.3.6         
[21] xfun_0.11              yaml_2.2.0            
[23] compiler_3.6.1         base64enc_0.1-3       
[25] htmltools_0.4.0        knitr_1.26            
[27] redoc_0.1.0.9000