Skip to content

Writing Unicode Text into Text File from R (in Windows)

3 messages · Duncan Murdoch, Majid Einian

#
On 14-02-04 5:49 AM, Majid Einian wrote:
There are a lot of places in R where it converts strings to the local 
encoding, perhaps too many. On the other hand, maybe Windows should be 
offering UTF-8 locales by now.

I haven't tested in your locale, but I believe writeLines() to a 
connection declared to be in a UTF-8 encoding will maintain the 
encoding.  You can declare a file to be in encoding "UTF-8-BOM" if you 
want to ignore a BOM on input; I forget whether it will write one on 
output.  If it doesn't, you can always write one explicitly.

I was hoping to make some progress on this before R 3.1.0 so that more 
cases of writing strings to UTF-8 files would work, but time is running out.

Duncan Murdoch
14 days later
#
On Tue, Feb 4, 2014 at 4:18 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
I would like to see that happen too! I have no such problem on Linux.
writeLines() does change the encoding to system encoding and then back
to unicode just like cat().
I have no problem with BOM being there or not.
I hope we see this happen soon :)

Majid Einian