From a5721d51bb47a7638d4d70b49c254fca37ca4c01 Mon Sep 17 00:00:00 2001 From: ncondits3 Date: Mon, 29 Jan 2024 20:52:30 -0500 Subject: [PATCH] Got rid of use of deprecated stri_enc_detect2() --- R/Read.R | 12 +++++++++--- R/humdrumR-package.R | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/R/Read.R b/R/Read.R index 2419a1f7..a910e357 100644 --- a/R/Read.R +++ b/R/Read.R @@ -311,9 +311,15 @@ readTextFiles <- function(fpaths) { if (length(fpaths) == 0L) return(character(0)) raw <- lapply(fpaths, stringi::stri_read_raw) - enc <- data.table::rbindlist(lapply(stringi::stri_enc_detect2(raw), head, n = 1)) - - text <- !is.na(enc$Encoding) & enc$Confidence >= 0.75 + enc <- data.table::rbindlist(lapply(stringi::stri_enc_detect(raw), head, n = 1)) + + # text <- !is.na(enc$Encoding) & enc$Confidence >= 0.75 + text <- stringi::stri_enc_isascii(raw) | + stringi::stri_enc_isutf16be(raw) | + stringi::stri_enc_isutf16le(raw) | + stringi::stri_enc_isutf32be(raw) | + stringi::stri_enc_isutf16le(raw) | + stringi::stri_enc_isutf8(raw) files <- unlist(Map(stringi::stri_encode, raw[text], enc$Encoding[text])) diff --git a/R/humdrumR-package.R b/R/humdrumR-package.R index 1ef80fc2..a329afb1 100644 --- a/R/humdrumR-package.R +++ b/R/humdrumR-package.R @@ -46,7 +46,7 @@ #' @importFrom glue glue glue_collapse #' @importFrom abind abind #' @importFrom stringr str_count str_detect str_dup str_extract str_match str_pad str_replace str_split str_sub str_sort -#' @importFrom stringi stri_enc_detect2 stri_read_raw stri_trans_totitle +#' @importFrom stringi stri_enc_detect stri_read_raw stri_trans_totitle stri_enc_isascii stri_enc_isutf16be stri_enc_isutf16le stri_enc_isutf32be stri_enc_isutf32be stri_enc_isutf8 #' @importFrom rlang %|% %||% #' @importFrom bit64 as.integer64 is.integer64 #' @importFrom numbers primeFactors