From 221f9bc46042b06669788e60c63d7e79d9a8e67b Mon Sep 17 00:00:00 2001 From: Emil Bode Date: Tue, 29 Sep 2020 18:03:21 +0200 Subject: [PATCH] Patch for issue #108 --- R/RcppExports.R | 4 +++- tests/testthat/test_encoding.R | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/R/RcppExports.R b/R/RcppExports.R index 50ebbcd..7731981 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -106,7 +106,9 @@ get_credentials <- function(urls) { #'@rdname encoder #'@export url_decode <- function(urls) { - .Call(`_urltools_url_decode`, urls) + url <- .Call(`_urltools_url_decode`, urls) + Encoding(url) <- 'UTF-8' + return(url) } #'@rdname encoder diff --git a/tests/testthat/test_encoding.R b/tests/testthat/test_encoding.R index 682de3e..1e93ddf 100644 --- a/tests/testthat/test_encoding.R +++ b/tests/testthat/test_encoding.R @@ -16,11 +16,12 @@ test_that("Check decoding can handle NAs", { expect_that(url_decode(c("https://foo.org/bar%2f", NA)), equals(c("https://foo.org/bar/", NA))) }) -# Add comment for windows trickery +# Windows should work as well after patch for issue #108 test_that("Check decoding and encoding are equivalent", { - if(.Platform$OS.type == "unix"){ + if(.Platform$OS.type %in% c("unix", "windows")){ url <- "Hinrichtung_auf_dem_Altst%c3%a4dter_Ring.JPG%2f120px-Hinrichtung_auf_dem_Altst%c3%a4dter_Ring.JPG" decoded_url <- "Hinrichtung_auf_dem_Altst\xc3\xa4dter_Ring.JPG/120px-Hinrichtung_auf_dem_Altstädter_Ring.JPG" + Encoding(decoded_url) <- 'UTF-8' expect_that((url_decode(url)), equals((decoded_url))) expect_that((url_encode(decoded_url)), equals((url))) }