(v3.0.1.9112) Fix detection of non-UTF-8 input in as.ab() and add_custom_antimicrobial_synonyms() on R 4.2 and older, where enc2utf8() escapes invalid bytes

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2026-10-10 12:49:13 +02:00
1 parent 31692a26d1
commit 01ca2b98ac
4 files changed
+16 -9

No files matched your search

+1 -1
View File
@@ -118,7 +118,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, language = get_AMR_locale(),
}
if (is.character(x)) {
x_unique <- unique(x[!is.na(x)])
invalid <- x %in% x_unique[!custom_ab_valid_utf8(enc2utf8(x_unique))]
invalid <- x %in% x_unique[!custom_ab_valid_utf8(x_unique)]
if (any(invalid)) {
warning_("in `as.ab()`: ", nr2char(sum(invalid)), " value", ifelse(sum(invalid) > 1, "s were", " was"), " not valid UTF-8 text and returned as `NA`. Convert such input first, e.g. with `iconv(x, from = \"CP949\", to = \"UTF-8\")`.")
x[invalid] <- NA_character_