diff --git a/R/meta.R b/R/meta.R index 69c3888..c33705d 100644 --- a/R/meta.R +++ b/R/meta.R @@ -38,7 +38,7 @@ meta <- function(x, ...) { #' @importFrom assertthat assert_that is.string noNA meta.character <- function(x, na = "NA", ...) { assert_that(is.string(na), noNA(na), no_whitespace(na)) - x <- iconv(x, to = "UTF-8") + x <- iconv(x, from = "UTF-8", to = "UTF-8") if (na %in% x) { stop("one of the strings matches the NA string ('", na, "') Please use a different NA string or consider using a factor.", call. = FALSE) @@ -80,7 +80,7 @@ meta.numeric <- function(x, ...) { #' @importFrom assertthat assert_that is.flag noNA meta.factor <- function(x, optimize = TRUE, na = "NA", index, ...) { assert_that(is.flag(optimize), noNA(optimize)) - levels(x) <- iconv(levels(x), to = "UTF-8") + levels(x) <- iconv(levels(x), from = "UTF-8", to = "UTF-8") if (missing(index) || is.null(index)) { index <- seq_along(levels(x)) names(index) <- levels(x) diff --git a/tests/testthat/setup_test_data.R b/tests/testthat/setup_test_data.R index 19a47e3..b8c3f4b 100644 --- a/tests/testthat/setup_test_data.R +++ b/tests/testthat/setup_test_data.R @@ -29,6 +29,9 @@ test_data <- data.frame( old_locale <- git2rdata:::set_c_locale() sorted_test_data <- test_data[order(test_data$test_Date), ] git2rdata:::set_local_locale(old_locale) +sorted_test_data$test_character <- iconv( + sorted_test_data$test_character, from = "UTF-8", to = "UTF-8" +) rownames(sorted_test_data) <- NULL attr(sorted_test_data$test_POSIXct, "tzone") <- "UTC" diff --git a/tests/testthat/test_b_special.R b/tests/testthat/test_b_special.R index d2552d2..387d12a 100644 --- a/tests/testthat/test_b_special.R +++ b/tests/testthat/test_b_special.R @@ -58,14 +58,14 @@ expect_equal( expect_equal( names(suppressWarnings(write_vc(ds, "test_data_hash", root)))[1], - "be6352bd3b0d1b3cd81739a5190c24a277ea16d5" + "c9e802041a28f322c94ba590607786a6bf8e590f" ) expect_silent({ output_test_data_hash <- read_vc("test_data_hash", root) }) expect_equal( names(attr(output_test_data_hash, "source")[1]), - "be6352bd3b0d1b3cd81739a5190c24a277ea16d5" + "c9e802041a28f322c94ba590607786a6bf8e590f" ) attr(output_test_data_hash, "source") <- NULL expect_equal(