gesistsa / rio

🐟 A Swiss-Army Knife for Data I/O
http://gesistsa.github.io/rio/
602 stars 76 forks source link

Issues in `export_methods` #318

Closed chainsawriot closed 1 year ago

chainsawriot commented 1 year ago
  1. ... is not consistently passed, although write_feather should be fine (there are only two arguments; but could be more in the future). But write_ods has more arguments now.

https://github.com/chainsawriot/rio/blob/01e55d2fd6dd1ee8c59ea782541d57353621d3c1/R/export_methods.R#L147-L150

https://github.com/chainsawriot/rio/blob/01e55d2fd6dd1ee8c59ea782541d57353621d3c1/R/export_methods.R#L250-L253

x <- tempfile(fileext = ".ods")
rio::export(mtcars, file = x, sheet = "mtcars")
#> Loading required namespace: readODS
readODS::list_ods_sheets(x)
#> [1] "Sheet1"

Created on 2023-08-30 with reprex v2.0.2

  1. cat is locale dependent; should set locale to UTF-8 ropensci/readODS#107

https://github.com/chainsawriot/rio/blob/01e55d2fd6dd1ee8c59ea782541d57353621d3c1/R/export_methods.R#L304-L307

https://github.com/chainsawriot/rio/blob/01e55d2fd6dd1ee8c59ea782541d57353621d3c1/R/export_methods.R#L206-L209

chainsawriot commented 1 year ago
chainsawriot commented 1 year ago

For 2, a technique is to use writeLines similar to readODS v2.0.0

.write_as_utf8 <- function(text, con) {
    writeLines(enc2utf8(text), con = con, sep = "", useBytes = TRUE)
}
chainsawriot commented 1 year ago

This GHA #331 run confirmed that exporting JSON on non-UTF-8 machines (e.g. R < 4.2 on Windows) is not UTF-8 safe. The same issue as readODS v1.8.0.