From 8bb78da4ac7a95cf9467b4a76deb4c7fb4f0834b Mon Sep 17 00:00:00 2001 From: Shawn Garbett Date: Mon, 13 Sep 2021 12:17:00 -0500 Subject: [PATCH] Modified as.utf8 to preserve attributes --- R/utils.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/utils.R b/R/utils.R index 0a2c3cc..e0e8f1a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,12 +1,14 @@ `as.utf8` <- function(x) { - if (is.character(x)) { - enc2utf8(x) + coded <- enc2utf8(x) + attributes(coded) <- attributes(x) + coded } else if (is.list(x)) { - lapply(x, as.utf8) + coded <- lapply(x, as.utf8) + attributes(coded) <- attributes(x) + coded } else { x } - } \ No newline at end of file