From c80c86b9a04b5044c39253bf6549e0a88c6c7f19 Mon Sep 17 00:00:00 2001 From: tomasy-j Date: Thu, 28 May 2026 14:19:42 -0700 Subject: [PATCH 1/5] use ellipsis instead of ... in prettyprint --- R/print.data.table.R | 2 +- inst/tests/tests.Rraw | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index 88ff4ea505..325756ce14 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -253,7 +253,7 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) { nchar_chars = nchar(x, 'char') is_full_width = nchar_width > nchar_chars idx = !is.na(x) & pmin(nchar_width, nchar_chars) > trunc.char - x[idx] = paste0(strtrim(x[idx], trunc.char * fifelse(is_full_width[idx], 2L, 1L)), "...") + x[idx] = paste0(strtrim(x[idx], trunc.char * fifelse(is_full_width[idx], 2L, 1L)), "\u2026") x } diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 483638099e..c68a98f29d 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -7266,7 +7266,7 @@ test(1514.9, fitsInInt64(9L), FALSE) # #1091 options(datatable.prettyprint.char = 5L) DT = data.table(x=1:2, y=c("abcdefghijk", "lmnopqrstuvwxyz")) -test(1515.1, grep("abcde...", capture.output(print(DT))), 2L) +test(1515.1, grep("abcde\u2026", capture.output(print(DT))), 2L) options(datatable.prettyprint.char = NULL) # test 1516: chain setnames() - used while mapping source to target columns @@ -18147,7 +18147,7 @@ ja_ko = "\u3053" ja_n = "\u3093" nc = c(accented_a, ja_ichi, ja_ni, ja_ko, ja_n) if (utf8_check(nc)) { - dots = "..." + dots = "\u2026" clean_regex = "^\\d+:\\s+" # removes row numbering from beginning of output # Tests for combining character latin a and acute accent, single row DT = data.table(strrep(accented_a, 4L)) @@ -18173,8 +18173,8 @@ if (utf8_check(nc)) { DT = data.table(paste0(ja_ichi), strrep(ja_ni, 2L), strrep(ja_ko, 3L), strrep(accented_a, 2L), "aaa") test(2253.13, options=list(datatable.prettyprint.char = 4L), capture.output(print(DT))[-1L], paste("1:", ja_ichi, strrep(ja_ni, 2L), strrep(ja_ko, 3L), strrep(accented_a, 2L), "aaa")) test(2253.14, options=list(datatable.prettyprint.char = 3L), capture.output(print(DT))[-1L], paste("1:", ja_ichi, strrep(ja_ni, 2L), strrep(ja_ko, 3L), strrep(accented_a, 2L), "aaa")) - test(2253.15, options=list(datatable.prettyprint.char = 2L), capture.output(print(DT))[-1L], paste("1:", ja_ichi, strrep(ja_ni, 2), paste0(strrep(ja_ko, 2), dots) , strrep(accented_a, 2), "aa...")) - test(2253.16, options=list(datatable.prettyprint.char = 1L), capture.output(print(DT))[-1L], paste("1:", ja_ichi, paste0(ja_ni, dots), paste0(ja_ko, dots), paste0(accented_a, dots), "a...")) + test(2253.15, options=list(datatable.prettyprint.char = 2L), capture.output(print(DT))[-1L], paste("1:", ja_ichi, strrep(ja_ni, 2), paste0(strrep(ja_ko, 2), dots) , strrep(accented_a, 2), "aa\u2026")) + test(2253.16, options=list(datatable.prettyprint.char = 1L), capture.output(print(DT))[-1L], paste("1:", ja_ichi, paste0(ja_ni, dots), paste0(ja_ko, dots), paste0(accented_a, dots), "a\u2026")) # Tests for multiple columns, multiple rows DT = data.table(strrep(ja_ko, 1:3L), strrep(ja_n, 2:4L), strrep(accented_a, 3)) test(2253.17, options=list(datatable.prettyprint.char = 4L), gsub(clean_regex, "", capture.output(print(DT))[-1L]), From 876581b182b4dd216ef0619d8dc46ef62a6b8126 Mon Sep 17 00:00:00 2001 From: tomasy-j Date: Fri, 29 May 2026 10:13:41 -0700 Subject: [PATCH 2/5] update tests 2253.20 and 2253.18 --- inst/tests/tests.Rraw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index c68a98f29d..cf9630536e 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -18182,15 +18182,15 @@ if (utf8_check(nc)) { paste0(strrep(ja_ko, 2L), " ", strrep(ja_n, 3L), " ", strrep(accented_a, 3L)), paste(strrep(ja_ko, 3L), strrep(ja_n, 4L), strrep(accented_a, 3L)))) test(2253.18, options=list(datatable.prettyprint.char = 3L), gsub(clean_regex, "", capture.output(print(DT))[-1L]), - c(paste0(ja_ko, " ", strrep(ja_n, 2L), " ", strrep(accented_a, 3L)), - paste0(strrep(ja_ko, 2L), " ", strrep(ja_n, 3L), " ", strrep(accented_a, 3L)), + c(paste0(ja_ko, " ", strrep(ja_n, 2L), " ", strrep(accented_a, 3L)), + paste0(strrep(ja_ko, 2L), " ", strrep(ja_n, 3L), " ", strrep(accented_a, 3L)), paste(strrep(ja_ko, 3L), paste0(strrep(ja_n, 3L), dots), strrep(accented_a, 3L)))) test(2253.19, options=list(datatable.prettyprint.char = 1L), gsub(clean_regex, "", capture.output(print(DT))[-1L]), c(paste0(ja_ko, " ", paste0(ja_n, dots), " ", paste0(accented_a, dots)), paste0(c(ja_ko, ja_n, accented_a), dots, collapse=" "), paste0(c(ja_ko, ja_n, accented_a), dots, collapse=" "))) # test for data.table with NA, #6441 - test(2253.20, options=list(datatable.prettyprint.char = 1L), data.table(a = c("abc", NA)), output=" a\n1: a...\n2: ") + test(2253.20, options=list(datatable.prettyprint.char = 1L), data.table(a = c("abc", NA)), output=" a\n1: a\u2026\n2: ") } else { cat("Tests 2253* skipped because they need a UTF-8 locale.\n") }}) From 73bd1404fb72b241ae020d7254acc60ace8bdbcc Mon Sep 17 00:00:00 2001 From: tomasy-j Date: Sat, 30 May 2026 11:01:48 -0700 Subject: [PATCH 3/5] check if UTF8 is supported for ellipsis, if not use dots --- R/print.data.table.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index 325756ce14..da9c4a8fa1 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -252,8 +252,9 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) { nchar_width = nchar(x, 'width') # Check whether string is full-width or half-width, #5096 nchar_chars = nchar(x, 'char') is_full_width = nchar_width > nchar_chars - idx = !is.na(x) & pmin(nchar_width, nchar_chars) > trunc.char - x[idx] = paste0(strtrim(x[idx], trunc.char * fifelse(is_full_width[idx], 2L, 1L)), "\u2026") + idx = !is.na(x) & pmin(nchar_width, nchar_chars) > trunc.char + dots = if (l10n_info()$'UTF-8') "\u2026" else "..." + x[idx] = paste0(strtrim(x[idx], trunc.char * fifelse(is_full_width[idx], 2L, 1L)), dots) x } From f0ddd1ad5b5830ac9bf90ea57facd3d1d37b9842 Mon Sep 17 00:00:00 2001 From: tomasy-j Date: Sat, 30 May 2026 11:05:11 -0700 Subject: [PATCH 4/5] rm trailing whitespaces --- R/print.data.table.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index da9c4a8fa1..fa95bb5640 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -252,8 +252,8 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) { nchar_width = nchar(x, 'width') # Check whether string is full-width or half-width, #5096 nchar_chars = nchar(x, 'char') is_full_width = nchar_width > nchar_chars - idx = !is.na(x) & pmin(nchar_width, nchar_chars) > trunc.char - dots = if (l10n_info()$'UTF-8') "\u2026" else "..." + idx = !is.na(x) & pmin(nchar_width, nchar_chars) > trunc.char + dots = if (l10n_info()$'UTF-8') "\u2026" else "..." x[idx] = paste0(strtrim(x[idx], trunc.char * fifelse(is_full_width[idx], 2L, 1L)), dots) x } From 74382b49400b0b33c444269b1a445171c7c93b08 Mon Sep 17 00:00:00 2001 From: tomasy-j Date: Mon, 1 Jun 2026 21:05:26 -0700 Subject: [PATCH 5/5] test for three dots fall back in case utf8 unavailable --- inst/tests/tests.Rraw | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index cf9630536e..ac9fc88d50 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -18188,13 +18188,18 @@ if (utf8_check(nc)) { test(2253.19, options=list(datatable.prettyprint.char = 1L), gsub(clean_regex, "", capture.output(print(DT))[-1L]), c(paste0(ja_ko, " ", paste0(ja_n, dots), " ", paste0(accented_a, dots)), paste0(c(ja_ko, ja_n, accented_a), dots, collapse=" "), - paste0(c(ja_ko, ja_n, accented_a), dots, collapse=" "))) + paste0(c(ja_ko, ja_n, accented_a), dots, collapse=" "))) # test for data.table with NA, #6441 test(2253.20, options=list(datatable.prettyprint.char = 1L), data.table(a = c("abc", NA)), output=" a\n1: a\u2026\n2: ") } else { cat("Tests 2253* skipped because they need a UTF-8 locale.\n") }}) +# Test that char.trunc in prettyprint falls back to three dots if ellipsis is not supported in non UTF-8 encoding +DT = data.table(a = c("abcd", NA, "f")) +test(2253.24, options = list(datatable.prettyprint.char = 3L,Sys.setlocale("LC_CTYPE", "C")), + DT, output = " a\n1: abc...\n2: \n3: f") + # allow 1-D matrix in j for consistency, #783 DT=data.table(a = rep(1:2, 3), b = 1:6) test(2254.1, DT[, .(cbind(b, b)), by=a], error="Entry 1 for group 1.*2 dimensions > 1")