On Thu, 23 Nov 2006, ronggui wrote:

> I would like to now if there a universal way to writing a character
> vector to a file in UTF-8 encoding? By " universal", I mean a way
> which works under Linux, Windows and Mac.

You need to know what encoding the character vector is in.  If you know it 
to be in the charset of the current locale, something like

z <- file("outfile", "w", encoding="UTF-8")
write(char_vector, file=z)
close(z)

If not, you could use iconv() to convert it to UTF-8 and then use write() 
without specifying the encoding.

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to