On Tue, 5 Jun 2007, Alberto Monteiro wrote:
> What is the inverse of encodeString?
>
> For example, \u1 is some Unicode symbol. If I do
>
> s <- encodeString("\u1")
>
> then s will be the string "\001". But anything I do
> with s, will not return the Unicode that corresponds to \u1:
>
> cat(s, "\n") # prints \001
> cat("\u1", "\n") # prints y with umlaut
Not on a properly operational UTF-8 system: your terminal has a problem.
The help says
'encodeString' escapes the strings in a character vector in the
same way 'print.default' does, and optionally fits the encoded
strings within a field width.
The printed representation is not necessarily invertible, but scan() would
be a good start:
> scan(con<-textConnection(s), "", allowEscapes=TRUE);
close(con)
Read 1 item
[1] "\001"
as might parse(text=) be.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
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