Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Nov 23, 2023
1 parent 651f5ef commit 9fab14a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/testthat/_snaps/utf8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# UTF-8 encoding, string input

Code
print(out_utf8[i_out])
Output
[1] "#> [1] \"À\" \"Ë\" \"Ð\""

---

Code
print(charToRaw(out_utf8[i_out]))
Output
[1] 23 3e 20 5b 31 5d 20 22 c3 80 22 20 22 c3 8b 22 20 22 c3 90 22

7 changes: 5 additions & 2 deletions tests/testthat/test-utf8.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ test_that("UTF-8 encoding, string input", {
)
out_utf8 <- reprex(input = in_utf8)

expect_true(all(Encoding(out_utf8) %in% c("unknown", "UTF-8")))

i_in <- grep("^x <-", in_utf8)
i_out <- grep("^x <-", out_utf8)
expect_identical(charToRaw(in_utf8[i_in]), charToRaw(out_utf8[i_out]))

i_out <- grep("^#> \\[1\\]", out_utf8)
expect_equal(Encoding(out_utf8)[i_out], "UTF-8")
expect_match(out_utf8[i_out], "[\u00C0]")
expect_match(out_utf8[i_out], "[\u00CB]")
expect_match(out_utf8[i_out], "[\u00D0]")

expect_snapshot(print(out_utf8[i_out]))
expect_snapshot(print(charToRaw(out_utf8[i_out])))
#expect_snapshot(print(Sys.getlocale()))

in_latin1 <- iconv(in_utf8, from = "UTF-8", to = "latin1")
out_latin1 <- reprex(input = in_latin1)

Expand Down

0 comments on commit 9fab14a

Please sign in to comment.