Skip to content
Prev 386035 / 398513 Next

write.csv covert Åland to <c5>land

Hi,

One additional option that you might want to look at is to use ?writeLines with 'useBytes = TRUE', where the default is FALSE.

Windows, as Duncan notes, is problematic with extended encodings, and you can actually get conflicted encoding of text, based upon what is used within R, versus the local system encoding set by the OS.

There is an added step of complexity with writeLines(), of having to pre-format the line(s) to be output to conform to CSV required formatting. So you would need to paste() together each output line first using field delimiters, double quotes, etc. prior to output. 

Essentially, mimic the default formatting of write.csv(), on a line by line basis, and then output the resulting object to a text file, with a single call to writeLines().

Regards,

Marc Schwartz