kota7/striprtf

read_rtf Chinese rtf

Closed this issue · 5 comments

I have a rtf file which is created by Simplified Chinese SAS , but read_rtf report an error. I want to help, how to read rtf file Simplified Chinese
@kota7
a <- striprtf::read_rtf("E:/R/test_cn.rtf")
Error in chartr(.cptable[[cpname]]$before, .cptable[[cpname]]$after, out[parsed$toconv]) :
invalid input '������������������������������ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ腀腁腂腃腄腅腆腇腈腉腊腋腌腍腎腏腐腑腒腓腔腕腖腗腘腙腚腛腜腝腞腟腠腡腢腣腤腥腦腧腨腩腪腫腬腭腮腯腰腱腲腳腴腵腶腷腸腹腺腻腼腽腾膀膁膂膃膄膅膆膇膈膉膊膋膌膍膎膏膐膑膒膓膔膕膖膗膘膙膚膛膜膝膞膟膠膡膢膣膤膥膦膧膨膩膪膫膬膭膮膯膰膱膲膳膴膵膶膷膸膹膺膻膼膽膾膿臀臁臂臃臄臅臆臇臈臉臊臋臌臍臎臏臐臑臒臓臔臕臖臗臘臙臚臛臜臝臞臟臠臡臢臣臤臥臦臧臨臩自臫臬臭臮臯臰臱臲至致臵臶臷臸臹臺臻臼臽臾艀艁艂艃艄艅艆艇艈艉艊艋艌艍艎艏艐艑艒艓艔艕艖艗艘艙艚艛艜艝艞艟艠艡艢艣艤艥艦艧艨艩艪艫艬艭艮良艰艱

test_cn.zip

kota14 commented

@r4shiny Thank you for letting me know. I will have a look.

kota7 commented

@r4shiny
The error itself has been fixed in the current github version (v0.6.0). There was a problem in the algorithm of converting across character code systems.
Please try using this version with devtools::install_github("kota7/striprtf") for now.

The result still has an issue of parsing the table contents correctly. This will be addressed in a separate issue #22.

Update of the CRAN version will happen some time later.
Thanks!

kota7 commented

Now the table seems to be parsed properly.

read_rtf("chinese-sas.rtf")
 [1] "SAS 系统"                                             ""                                                    
 [3] "*| 姓名 | 性别 | 年龄 | 身高(英寸) | 体重(磅) | " "*| 阿尔弗雷德 | 男 | 14 | 69 | 112.5 | "             
 [5] "*| 爱丽丝 | 女 | 13 | 56.5 | 84 | "                   "*| 芭芭拉 | 女 | 13 | 65.3 | 98 | "                  
 [7] "*| 凯露 | 女 | 14 | 62.8 | 102.5 | "                  "*| 亨利 | 男 | 14 | 63.5 | 102.5 | "                 
 [9] "*| 詹姆斯 | 男 | 12 | 57.3 | 83 | "                   "*| 简 | 女 | 12 | 59.8 | 84.5 | "                    
[11] "*| 雅妮特 | 女 | 15 | 62.5 | 112.5 | "                "*| 杰弗瑞 | 男 | 13 | 62.5 | 84 | "                  
[13] "*| 约翰 | 男 | 12 | 59 | 99.5 | "                     "*| 乔伊斯 | 女 | 11 | 51.3 | 50.5 | "                
[15] "*| 茱迪 | 女 | 14 | 64.3 | 90 | "                     "*| 罗伊斯 | 女 | 12 | 56.3 | 77 | "                  
[17] "*| 玛丽 | 女 | 15 | 66.5 | 112 | "                    "*| 菲利普 | 男 | 16 | 72 | 150 | "                   
[19] "*| 罗伯特 | 男 | 12 | 64.8 | 128 | "                  "*| 罗纳德 | 男 | 15 | 67 | 133 | "                   
[21] "*| 托马斯 | 男 | 11 | 57.5 | 85 | "                   "*| 威廉 | 男 | 15 | 66.5 | 112 | "                   
[23] ""                                                     ""    

@kota7 Thank you so much!I tested it , now it works. I'm a little excited,maybe you don't know, this package solved my a major problem. Your work is really the technology light to me.
Thank you so much!非常感谢!

kota7 commented

@r4shiny My pleasure! Good luck with your project.