Skip to content
Prev 51586 / 63421 Next

iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param)

On 24/02/2016 9:55 AM, Mikko Korpela wrote:
It looks like a big change is needed for a perfect solution:

  - Windows does the translation of \n to \r\n.  In the R code, Windows 
is never told that the output is UTF-16LE, so it does an 8 bit translation.

  - Telling Windows that output is UTF-16LE looks hard:  we'd need to
convert the string to wide chars in R, then write it in wide chars. 
This seems like a lot of work for a rare case.

  - It might be easier to do a hack:  if the user asks for "UTF-16LE", 
then treat it internally as a text file but tell Windows it's a binary 
file.  This means no \n to \r\n translation will be done by Windows.  If 
the desired output file needs Windows line endings, the user would have 
to specify sep="\r\n" in writeLines.

Duncan Murdoch

Thread (15 messages)

nospam at altfeld-im.de iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 16 nospam at altfeld-im.de iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 22 Martin Maechler iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 23 Mikko Korpela iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 23 nospam at altfeld-im.de iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 23 Duncan Murdoch iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 23 Duncan Murdoch iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 24 Mikko Korpela iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 24 Duncan Murdoch iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 24 Duncan Murdoch iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 24 Mikko Korpela iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 25 Peter Dalgaard iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 25 Mikko Korpela iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 25 Duncan Murdoch iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 29 Mikko Korpela iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param) Feb 29