From 89dbfcecbf625c30ccd9ac20d51bf58dbdeaeff8 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Mon, 11 May 2020 13:42:10 -0500 Subject: [PATCH] Ensure file encoding is specified for sort_c --- R/utils.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/utils.R b/R/utils.R index 73884e3a4..0b211784b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -213,6 +213,10 @@ sortByName <- function(x) { # Sort a vector. If a character vector, sort using C locale, which is consistent # across platforms. Note that radix sort uses C locale according to ?sort. sort_c <- function(x, ...) { + # Use UTF-8 encoding, because if encoding is "unknown" for non-ASCII + # characters, the sort() will throw an error. + if (is.character(x)) + x <- enc2utf8(x) sort(x, method = "radix", ...) }