Closed jszhao closed 6 years ago
Alternative way is to use stringi
package, something like:
require(stringi)
curr_enc <- stri_enc_get()
string <- stri_conv(string, from = curr_enc, to = "UTF-8") #now string is in UTF-8
Your solution seems to be correct to me. Could you send a pull request? Thanks!
Because I am not familiar with git, I don't know how to pull request. I will try later.
Because I don't know how to pull request on Github, I just paste the diff here, so someone can help. Thanks!
--- tikzDevice-master/R/deviceUtils.R 2016-06-21 14:18:12.000000000 +0800
+++ tikzDevice/R/deviceUtils.R 2017-04-04 11:28:27.741878200 +0800
@@ -231,9 +231,9 @@
mb <- FALSE
- # Set the encoding of the string if it is not explicitly set
- if(Encoding(string) == "unknown")
- Encoding(string) <- encoding
+# # Set the encoding of the string if it is not explicitly set
+# if(Encoding(string) == "unknown")
+# Encoding(string) <- encoding
# convert the string to UTF-8
string <- enc2utf8(string)
That is okay. Much appreciated!
If you want to try Github pull requests anyway, it is actually pretty simple and here is how: go to https://github.com/yihui/tikzDevice/blob/master/R/deviceUtils.R, hit the edit button (the button on the left side of the trash button), remove the lines you mentioned, scroll to the bottom of the page, write a message, and Github will guide you to create a pull request. I think it will be fun to send your first pull request :)
@yihui thanks for the guide. I have created a pull request https://github.com/yihui/tikzDevice/pull/158.
The bug is in the following line
here is a mini example that demo the bug:
I think the above two lines could be remove, since
string <- enc2utf8(string)
does all needed.