bypass base::format if encoding utf8
With Windows 10 and locale = Danish_Denmark.1252, the base::format function in solve_enc messed up the encoding if the string was already encoded in UTF-8, e.g. character string = "\u2265"
diff --git a/R/util.R b/R/util.R
index 12cc526..e01b4dc 100644
--- a/R/util.R
+++ b/R/util.R
@@ -152,8 +152,12 @@
# Solve enc issue for LaTeX tables
solve_enc <- function(x) {
+ if (Encoding(x) == "UTF-8"){
+ out <- x
+ } else {
#may behave differently based on Sys.setlocale settings with respect to characters
- out <- enc2utf8(as.character(base::format(x, trim = TRUE, justify = 'none')))
+ out <- enc2utf8(as.character(base::format(x, trim = TRUE, justify = 'none')))
+ }
mostattributes(out) <- attributes(x)
return(out)
}