jonkeane commented on a change in pull request #12030:
URL: https://github.com/apache/arrow/pull/12030#discussion_r779103165
##########
File path: r/tests/testthat/test-csv.R
##########
@@ -290,6 +292,50 @@ test_that("more informative error when reading a CSV with
headers and schema", {
)
})
+test_that("CSV reader works on files with non-UTF-8 encoding", {
+ strings <- c("a", "\u00e9", "\U0001f4a9")
+ file_string <- paste0(
+ "col1,col2\n",
+ paste(strings, 1:30, sep = ",", collapse = "\n")
+ )
+ file_bytes_utf16 <- iconv(
+ file_string,
+ from = Encoding(file_string),
+ to = "UTF-16LE",
+ toRaw = TRUE
+ )[[1]]
+
+ tf <- tempfile()
+ on.exit(unlink(tf))
+ con <- file(tf, open = "wb")
+ writeBin(file_bytes_utf16, con)
+ close(con)
+
+ fs <- LocalFileSystem$create()
+ reader <- CsvTableReader$create(
+ fs$OpenInputStream(tf),
+ read_options = CsvReadOptions$create(encoding = "UTF-16LE")
+ )
Review comment:
What happens if someone calls this without specifying the encoding?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]