diff --git a/R/guess.r b/R/guess.r index 1a0fc41f..6d2420fa 100644 --- a/R/guess.r +++ b/R/guess.r @@ -338,7 +338,7 @@ guess_formats <- function(x, orders, locale = Sys.getlocale("LC_TIME"), p <- p[nzchar(p)] alpha["p"] <- if ( length(p) == 0L ) "" - else sprintf("(?

%s)(?![[:alpha:]])", paste(p, collapse = "|")) + else sprintf("(?

%s)(?![[:alpha:]])", paste(p, collapse = "|")) alpha <- unlist(alpha) @@ -405,10 +405,10 @@ guess_formats <- function(x, orders, locale = Sys.getlocale("LC_TIME"), num_exact <- num_flex <- num num_flex[] <- sprintf("%s(?!\\d)", num) - - num_exact[] <- gsub("(?", "_e>", num))) # append _e to avoid duplicates + ## it is crittcal tu use fixed = TRUE because of the multibyte bug #181 + num_exact[] <- gsub("(?", "_e>", num, fixed = TRUE))) # append _e to avoid duplicates num_flex["m"] <- sprintf("((?1[0-2]|0?[1-9](?!\\d))|(%s))", gsub("_[bB]", "\\1_m", alpha[["b"]])) num_exact["m"] <- sprintf("((?1[0-2]|0[1-9])|(%s))", gsub("_[bB]", "\\1_m_e>", alpha[["b"]])) diff --git a/inst/tests/test-parsers.R b/inst/tests/test-parsers.R index 74f2b75f..00f4f36c 100644 --- a/inst/tests/test-parsers.R +++ b/inst/tests/test-parsers.R @@ -535,6 +535,8 @@ test_that("ymd_hms parses OO and Oo formats correctly", { ## x_RU2 <- "Вт. 2012 авг. 14 11:52:57 " ## ymd_hms(c(x_RU, x_RU2), locale = "ru_RU.utf8") +## Sys.setlocale("LC_TIME", "ja_JP.utf8") +## format(Sys.time(), format = "%A %Y %B %d %I:%M:%S %p") ## gsub("([].|(){^$*+?[])", "\\\\\\1", "sdfs.") @@ -561,4 +563,4 @@ test_that("ymd_hms parses OO and Oo formats correctly", { ## guess_formats("101010202020", "ymdT") ## guess_formats("001020", "ymd") -## guess_formats("10 am", "r") \ No newline at end of file +## guess_formats("10 am", "r")