diff --git a/NEWS.md b/NEWS.md index 798796a56..734cccd0d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,9 @@ CHANGES * `recode_into()` gains an `overwrite` argument to skip overwriting already recoded cases when multiple recode patterns apply to the same case. +* `data_read()` now passes the `encoding` argument to `data.table::fread()`. + This allows to read files with non-ASCII characters. + * `datawizard` moves from the GPL-3 license to the MIT license. BUG FIXES diff --git a/R/data_read.R b/R/data_read.R index a4294e67b..2c3061570 100644 --- a/R/data_read.R +++ b/R/data_read.R @@ -271,7 +271,11 @@ data_read <- function(path, .read_text <- function(path, encoding, verbose, ...) { if (insight::check_if_installed("data.table", quietly = TRUE)) { - out <- data.table::fread(input = path, ...) + # set proper default encoding-value for fread + if (is.null(encoding)) { + encoding <- "unknown" + } + out <- data.table::fread(input = path, encoding = encoding, ...) class(out) <- "data.frame" return(out) }