Giter VIP home page Giter VIP logo

Comments (4)

elong0527 avatar elong0527 commented on August 15, 2024 1

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"

from r2rtf.

elong0527 avatar elong0527 commented on August 15, 2024

Thanks for the suggestions.

  1. For Chinese characters, please refer #89 and uses r2rtf:::utf8Tortf function.
  2. You can set text_convert = FALSE in rtf_colheader and rtf_body etc to avoid replacing _ to \sub.

from r2rtf.

cglaze11 avatar cglaze11 commented on August 15, 2024

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  AL01211单剂量递增研究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:
utf2rtf

I couldn't figure out why the result of r2rtf:::utf8Tortf was NA.

> r2rtf:::utf8Tortf("表3.1  AL01211单剂量递增研究PK参数汇总(PKS)")
[1] "NA"

Whether is the problem of function utf8ToInt?

> utf8ToInt("表")
[1] NA
> utf8ToInt("a")
[1] 97

from r2rtf.

cglaze11 avatar cglaze11 commented on August 15, 2024

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!

from r2rtf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.