tests/testthat/test-utils.R

test_that("converts Latin1 encoded text to utf8", {
  x <- "'\xfc'"
  Encoding(x) <- "latin1"

  y <- safe_parse(x)[[1]]
  expect_equal(Encoding(y), "UTF-8")
  expect_equal(y, "\u00fc")
})

test_that("doesn't crash on utf-8 characters", {
  expect_equal(safe_parse("×"), NULL)
})

Try the downlit package in your browser

Any scripts or data that you put into this service are public.

downlit documentation built on June 22, 2024, 9:17 a.m.