[R] encoding question again

Matthias Wendel office at matthiaswendel.de
Fri Dec 28 14:40:29 CET 2007


 
Hi, 
I'm running the actual R version in JGR (version 1.5-8 ). 
Sys.getlocale(category = "LC_ALL") yields 
	[1] "LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252"

I want to write some HTML-Code enhanced by statistical results and labels encoded in Latin-1, which I pass to a function. Some label shall generate the filename. Although the labels are correctly handled in JGR they are somehow converted when they are written to the file. Also the filename is not constructed as wanted. The function definition is correctly sourced into R. The function is defined like this:

Itemtabelle.head <- function (abt ){
   # nür zöm TÄST
   abt = iconv(abt,"UTF-8","LATIN1")   
   zz = file( paste("Itemtabelle/Itemtabelle", abt, ".html"), "wt", encoding = "LATIN1")
   cat(as.character("<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\">  \n"),
       as.character("   <head>                                                                                                                                                \n"),
		.
		.
		.
       as.character("        <td colspan=5 class=xl28 width=727 style=\'width:545pt\'>Gesundheitsindikatoren:  "), abt, as.character("</td>                                   \n"),
       as.character("       </tr>                                                                                                                                               "), file = zz)
       close(zz)
       unlink(zz)
}
Setting abt as " Ärzte Innere, Gynäkologie" and calling the function with this argument, yields a filename "Itemtabelle  Ärzte Innere, Gynäkologie .html" and in the file a line 
         <td colspan=5 class=xl28 width=727 style='width:545pt'>Gesundheitsindikatoren:    Ärzte Innere, Gynäkologie </td>  
is generated.                                 .
The problem remains the same in the rgui and rterm - except in rterm the resulting filename is "Itemtabelle Žrzte Innere, Gyn„kologie  .html".

Cheers,
Matthias
 



More information about the R-help mailing list