On Thursday 01 February 2007 14:18, Peter Dalgaard wrote:
> so you should convert it:
> > iconv("Im B\xfcro", from="latin1", to="UTF-8")
>
> [1] "Im Büro"
>
> > iconv("Im B\374ro",from="latin1", to="UTF-8")
>
> [1] "Im Büro"

I see. Thanks!

Any chances of adding something like this to read.spss()?
read.spss <- function([...], encoding=NULL) {
        [...]
        if (!is.null(encoding)) {
                iconv.recursive <- function(x, from) {
                        attribs <- attributes(x);
                        if (is.character(x)) {
                                x <- iconv(x, from=from, to="", sub="")
                        } else if (is.list(x)) {
                                x <- lapply(x, function(sub) 
iconv.recursive(sub, from))
                        }
                        # convert factor levels and all other attributes
                        attributes(x) <- lapply(attribs, function(sub) 
iconv.recursive(sub, from))
                        x
                }

                convert.recursive(rval, from=encoding)
        } else {
                rval
        }
}

Now that I've written this iconv.recursive() function once, I'm fine. But I 
guess something like this might be useful to others as well.

Regards
Thomas

Attachment: pgpzGuoLD95Bi.pgp
Description: PGP signature

______________________________________________
[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