mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 04:20:53 +01:00
(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:
1 parent
31692a26d1
commit
01ca2b98ac
4 files changed
+16
-9
No files matched your search
@@ -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_
|
||||
|
||||
Reference in new issue
Block a user