My .Rmd
file contains multilingual text. When I load the html page produced by knit2html
to my joomla site the multilingual text has been replaced by squares. Do you know of a way to request a utf-8
encoded html page, or any other way to overcome the problem?
我的.Rmd文件包含多语言文本。当我将knit2html生成的html页面加载到我的joomla网站时,多语言文本已被方块替换。你知道一种方法来请求一个utf-8编码的html页面,或任何其他方法来克服这个问题?
1 个解决方案
#1
5
Update:
更新:
RStudio (>= 0.97.x) and knitr (>= 1.2) know how to handle the file encoding now. RStudio will pass the file encoding to the encoding
argument of knit()
(e.g. knit('foo.Rmd', encoding = 'UTF-8')
). In short, upgrading RStudio and knitr will solve the problem.
RStudio(> = 0.97.x)和knitr(> = 1.2)现在知道如何处理文件编码。 RStudio将文件编码传递给knit()的编码参数(例如knit('foo.Rmd',encoding ='UTF-8'))。简而言之,升级RStudio和knitr将解决问题。
Please ignore the answer below; it is no longer an appropriate solution.
请忽略以下答案;它不再是一个合适的解决方案。
I did it like this (using RStudio):
我是这样做的(使用RStudio):
- For the
.Rmd
I chose "Save with encoding" then I selectedUTF-8
- 对于.Rmd,我选择了“使用编码保存”,然后选择了UTF-8
- Before calling
knit2html()
I gave:options(encoding = 'UTF-8')
- 在调用knit2html()之前我给了:options(encoding ='UTF-8')
That did the trick
这就是诀窍
#1
5
Update:
更新:
RStudio (>= 0.97.x) and knitr (>= 1.2) know how to handle the file encoding now. RStudio will pass the file encoding to the encoding
argument of knit()
(e.g. knit('foo.Rmd', encoding = 'UTF-8')
). In short, upgrading RStudio and knitr will solve the problem.
RStudio(> = 0.97.x)和knitr(> = 1.2)现在知道如何处理文件编码。 RStudio将文件编码传递给knit()的编码参数(例如knit('foo.Rmd',encoding ='UTF-8'))。简而言之,升级RStudio和knitr将解决问题。
Please ignore the answer below; it is no longer an appropriate solution.
请忽略以下答案;它不再是一个合适的解决方案。
I did it like this (using RStudio):
我是这样做的(使用RStudio):
- For the
.Rmd
I chose "Save with encoding" then I selectedUTF-8
- 对于.Rmd,我选择了“使用编码保存”,然后选择了UTF-8
- Before calling
knit2html()
I gave:options(encoding = 'UTF-8')
- 在调用knit2html()之前我给了:options(encoding ='UTF-8')
That did the trick
这就是诀窍