Closed cglaze11 closed 8 months ago
Thanks for the suggestions.
r2rtf:::utf8Tortf
function. text_convert = FALSE
in rtf_colheader
and rtf_body
etc to avoid replacing _
to \sub
.Thanks for the answer.
The reason that I tried to replaced \fcharset161
with \fcharset134
was the function r2rtf:::utf8Tortf
which didn't work.
the code:
final %>%
rtf_page(orientation = "landscape") %>%
rtf_title(r2rtf:::utf8Tortf("表3.1 单剂量递增研究PK参数汇总(PKS)")) %>%
rtf_colheader(
colheader = "剂量组|统计_量| Cmax\n (ng/mL)|tmax\n (h) |t1/2\n (h)| CL/F\n (L/h)|VZ/F\n (L)|AUC0-24h\n (ng/mL·h)
|AUC0-last\n (ng/mL·h)|AUC0-\\infty\n (ng/mL·h)|Kel\n (1/h)|%AUCexp\n (%)|CLr\n (L/h)"
) %>%
rtf_body() %>%
rtf_encode() %>%
write_rtf("Outputs/TFLs/T_3_1-2.rtf")
and output:
I couldn't figure out why the result of r2rtf:::utf8Tortf
was NA
.
> r2rtf:::utf8Tortf("表3.1 单剂量递增研究PK参数汇总(PKS)")
[1] "NA"
Whether is the problem of function utf8ToInt
?
> utf8ToInt("表")
[1] NA
> utf8ToInt("a")
[1] 97
Could you provide your session information using sessionInfo()
?
I can not reproduce the issue from Posit Cloud https://posit.cloud
Below is the output I get.
> library(r2rtf)
> utf8ToInt("表")
[1] 34920
> utf8ToInt("a")
[1] 97
One possibility is that your computer is not using UTF-8 encoding. Please check the encoding by
> Encoding("表")
[1] "UTF-8"
You are right. The locale isn't UTF-8
.
> Encoding("表")
[1] "unknown"
> sessionInfo()
locale:
[1] LC_COLLATE=English_United States.936 LC_CTYPE=English_United States.936
[3] LC_MONETARY=English_United States.936 LC_NUMERIC=C
[5] LC_TIME=English_United States.936
I set locale to UTF-8
.
Sys.setlocale("LC_ALL", "German.UTF-8")
Then all chinese character displayed right. Thanks very much again!
Problems description
Encoding
When output .rtf with package r2rtf in Rstudio of UTF-8,
Chinese characters cann‘’t be compiled correctly,like this:![wrong](https://github.com/Merck/r2rtf/assets/56330445/ebd8a40d-83da-4a3c-95a9-e2af8fae054f)
LaTex Code
another problem is the LaTeX code. When the subline
_
would be replaced with\sub
, the following situation occured.统计_量 was showed as 统计量.
My solution
Finally, I found the problem may be rtf code![right](https://github.com/Merck/r2rtf/assets/56330445/ce9af4aa-56a2-4de5-96bf-7f15e3b65388)
\fcharsetN
. When I replaced\fcharset161
with\fcharset134
, everything looked normal.Advise
Whether there is a need for improvement about function as_rtf_font
how function convert can solve the subscript problem?