Skip to content
Prev 212017 / 398500 Next

file reading /problems with encoding

Hello,

I'm a little frightened because of a problem that occured lately as I  
tried to read in a xml-file (for replacing some variables in the  
string with values from a data frame). The almost biggest problem is  
the encoding of the xml-file. Since it is generated by Word 2007 its  
encoding is UTF-8 (as to see in the xml-header).
Now I'm establishing a file connection with
For reading the whole file, I'm using the readLines()-function as follows
Eventually I'm merging the lines of this data frame with the following
(is there a better way of doing this?)

However, when I execute those lines, I get a warning like:
"incorrect input in the input-connection"
When I read the output variable xml, it's kind of clear: The string  
stops at a combination of chinese or japanese characters (which  
normally shouldn't be a problem for UTF-8 encoding).

So that is the problem. How am I able to read in the whole xml-file as  
a string in R? I need to have the correct encoding, because I want to  
grep after special character like "?".

Thank you for your help!

Kind regards, Tom


p.s. I'm not likely to use the XML-package, since I didn't want to  
parse the xml file :)