Skip to content

Commit

Permalink
Modified as.utf8 to preserve attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
spgarbet committed Sep 13, 2021
1 parent 5be7bcd commit 8bb78da
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -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
}

}

0 comments on commit 8bb78da

Please sign in to comment.