[R] Find out what "native.enc" corresponds to

Milan Bouchet-Valat nalimilan at club.fr
Sun Aug 5 10:54:03 CEST 2012


Hi!

I'm using R2HTML in my RcmdrPlugin.temis package to output localized
strings to a HTML file. Thus, I insert a simple header at the top of the
file to specify what encoding is used; if I don't do that, Web browsers
assume it is latin1, which is not always true.

My problem is, I could not find a way to detect what encoding is used by
R2HTML in the most general case. R2HTML simply calls cat() with the file
name, which means the text connection is opened using file(encoding =
getOption("encoding")). This is fine, except that when
getOption("encoding")) is set to "native.enc", I'm not able to find out
the real encoding that was used for output.

Of course, ideally I would tell R2HTML to output everything as UTF-8,
and I would add this information to the header. But AFAICT this is not
possible in the current state of this package. So I would be very
grateful if somebody could provide me with a solution to resolve
"native.enc" to the encoding name.

Thanks for your help



More information about the R-help mailing list