Skip to content

Commit

Permalink
add from = "UTF-8" argument to iconv() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Oct 22, 2019
1 parent 4cc3774 commit 05993c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/setup_test_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_b_special.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 05993c4

Please sign in to comment.