Skip to content

Commit 69d9555

Browse files
committed
suppressWarnings(Sys.setlocale(...))
On modern versions of R for Windows, Sys.setlocale() warns for non-UTF-8 locales. Also comment the previous instance of suppressWarnings().
1 parent 4f04422 commit 69d9555

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

inst/tests/tests.Rraw

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16996,7 +16996,8 @@ if (.Platform$OS.type=="windows") local({
1699616996
LC_TIME = "Chinese (Simplified)_China.936"
1699716997
)
1699816998
x_old = Map(Sys.getlocale, names(x))
16999-
invisible(Map(Sys.setlocale, names(x), x))
16999+
# setlocale() warns for non-UTF-8 locales in modern versions of R, #7210
17000+
suppressWarnings(invisible(Map(Sys.setlocale, names(x), x)))
1700017001
on.exit(Map(Sys.setlocale, names(x_old), x_old))
1700117002
# triggered segfault here in #4402, Windows-only under translation.
1700217003
# test that the argument order changes correctly (the 'item 2' moves to the beginning of the message)
@@ -18620,6 +18621,7 @@ local(if (l10n_info()$`UTF-8` || {
1862018621
lc_wantctype = 'en_US.UTF-8'
1862118622
# Japanese multibyte characters require utf8. As of 2025, we're likely to be already running in a UTF-8 locale, but if not, try this setlocale() call as a last chance.
1862218623
# Unfortunately, there is no guaranteed, portable way of switching to UTF-8 US English.
18624+
# Avoid the warning upon possible failure, #7210.
1862318625
lc_newctype = suppressWarnings(Sys.setlocale('LC_CTYPE', lc_wantctype))
1862418626
if (identical(lc_newctype, lc_wantctype)) {
1862518627
on.exit(Sys.setlocale('LC_CTYPE', lc_ctype))

0 commit comments

Comments
 (0)