Closed jszhao closed 6 years ago
This change can solve the https://github.com/yihui/tikzDevice/issues/154 partially. However, the encoding of final output file can not be controlled from the R code. In the https://github.com/yihui/tikzDevice/issues/154, the final output file is in UTF-8 encoding. If I change 模式
to 中文
, the final file is in encoding CP936. I don't find a clue to solve it, because I am know nothing about C.
In fact, the encoding of a file can be precisely controlled from R. The original authors of this package seem to like using file()
connections, which are unnecessary in my eyes.
In this case, if you want the file to be precisely encoded in UTF8, the correct way is first enc2utf8()
, then writeLines(useBytes = TRUE)
. From my experience, file(encoding = 'UTF-8')
cannot guarantee the output file is encoded in UTF-8 on Windows.
I think all files to be encoded in UTF-8 is a acceptable or best way. It also simplifies the code. However, how to encode the final output file generated by tikz
in UTF-8. The file is not generated by R code, but by C code.
Thanks!
Make the encoding of temporal TeX file
tikzStringWidthCalc.tex
to UTF-8, so that the xelatex and lualatex can compile the file correctly.Closes #154.