tests/testthat/test-encoding.R

test_that("can guess encoding", {
  skip("currently broken")
  skip_on_os("linux") # some hidden dependency on system library

  path <- system.file("html-ex", "bad-encoding.html", package = "rvest")
  x <- read_html(path)

  expect_snapshot(html_encoding_guess(x))
  # deprecated
  expect_snapshot(guess_encoding(x))
})

test_that("encoding repair is deprecated", {
  skip("currently broken")
  skip_on_cran()
  skip_on_os("linux") # some hidden dependency on system library

  path <- system.file("html-ex", "bad-encoding.html", package = "rvest")
  x <- read_html(path)
  text <- html_text(html_element(x, "p"))

  expect_snapshot(repair_encoding(text), error = TRUE)
  expect_snapshot(repair_encoding(text, "ISO-8859-1"))
})

Try the rvest package in your browser

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

rvest documentation built on June 22, 2024, 10:47 a.m.