View | Details | Raw Unified | Return to bug 16738
Collapse All | Expand All

(-)src/library/base/R/files.R (-2 / +5 lines)
Lines 50-59 Link Here
50
        for(i in seq_along(files)) {
50
        for(i in seq_along(files)) {
51
            f <- files[i]
51
            f <- files[i]
52
            tf <- tempfile()
52
            tf <- tempfile()
53
            tmp <- readLines(f, warn = FALSE)
53
            tmp <- list(readBin(f, "raw", file.size(f)))
54
            tmp2 <- try(iconv(tmp, encoding, "", "byte"))
54
            tmp2 <- try(iconv(tmp, encoding, "", "byte"))
55
            if(inherits(tmp2, "try-error")) file.copy(f, tf)
55
            if(inherits(tmp2, "try-error")) file.copy(f, tf)
56
            else writeLines(tmp2, tf)
56
            else {
57
                tmp2 <- strsplit(tmp2, "\r\n?|\n", perl = TRUE)[[1L]]
58
                writeLines(tmp2, tf)
59
            }
57
            files[i] <- tf
60
            files[i] <- tf
58
            if(delete.file) unlink(f)
61
            if(delete.file) unlink(f)
59
        }
62
        }

Return to bug 16738