Skip to content

Commit 959cb38

Browse files
committed
Remove tests for reencoding unknown encodings
1 parent 8ef43af commit 959cb38

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

tests/testthat/_snaps/c-api.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,3 @@
4141
Output
4242
<simpleError in r_obj_encode_utf8(c(enc, bytes)): translating strings with "bytes" encoding is not allowed>
4343

44-
---
45-
46-
Code
47-
(expect_error(r_obj_encode_utf8(c(enc, bytes))))
48-
Output
49-
<simpleError in r_obj_encode_utf8(c(enc, bytes)): translating strings with "bytes" encoding is not allowed>
50-

tests/testthat/helper-c-api.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ test_encodings <- function() {
2323
string <- "\u00B0C"
2424

2525
utf8 <- iconv(string, from = Encoding(string), to = "UTF-8")
26-
unknown <- iconv(string, from = Encoding(string), to = "", mark = FALSE)
2726
latin1 <- iconv(string, from = Encoding(string), to = "latin1")
2827

29-
list(utf8 = utf8, unknown = unknown, latin1 = latin1)
28+
# We used to be able to detect unknown encodings via `LEVELS()`. In recent
29+
# versions of R we need to use `Rf_charIsUTF8` instead to be conformant to the
30+
# public API but unfortunately it treats unknown encodings as UTF-8. So we
31+
# no longer support this case:
32+
#
33+
# ```
34+
# unknown <- iconv(string, from = Encoding(string), to = "", mark = FALSE)
35+
# ```
36+
37+
list(utf8 = utf8, latin1 = latin1)
3038
}
3139
expect_utf8_encoded <- function(object) {
3240
expect_identical(Encoding(object), rep("UTF-8", length(object)))

0 commit comments

Comments
 (0)