From therneau at mayo.edu  Fri Mar 31 19:03:26 2017
From: therneau at mayo.edu (Therneau, Terry M., Ph.D.)
Date: Fri, 31 Mar 2017 12:03:26 -0500
Subject: [Rd] iconv documentation error
Message-ID: <47cabe$64tuom@ironport10.mayo.edu>

This caught us yesterday when a string that we assumed to be in UTF-8 was actually using 
CP1252.  (This came from an internal web based service, so the root cause is not R's 
fault.)  The help page for iconv states that the result of an invalid conversion is NA 
only when the toRaw argument is TRUE, but this appears to be true in general.

Example:

test1 <- "M?ni?re's disease"        # the offending string (it was buried in a 13000 
character result string)
test2 <- iconv(test1, to="CP1252")  # create a version of the string that is in 
Window-1252 coding
iconv(test2, from="UTF-8")          # reprise our error
[1] NA

Note that Encoding(test2) returns "latin-1", which is also not quite in alignment with the 
help page.



[Rd] iconv documentation error
Therneau, Terry M., Ph.D.