Skip to content

Commit 3de7946

Browse files
Merge pull request #330 from yutannihilation/test-windows-encoding-issue
Use the dev version of enc package to fix handling non-ASCII characters on Windows
2 parents 7e451b2 + ae4ca88 commit 3de7946

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ Collate:
6666
'vertical.R'
6767
'visit.R'
6868
'zzz.R'
69+
Remotes:
70+
krlmlr/enc

tests/testthat/test-encoding.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
context("non-ASCII characters are handled properly")
2+
3+
test_that("non-ASCII characters are handled properly", {
4+
skip_if(.Platform$OS.type != "windows")
5+
6+
withr::with_locale(
7+
c(LC_CTYPE = "English_United States.1252"),
8+
{
9+
tmp <- tempfile(fileext = ".R")
10+
con <- file(tmp, encoding = "UTF-8")
11+
on.exit(close(con), add = TRUE)
12+
13+
# c.f. dplyr's tests/testthat/helper-encoding.R
14+
writeLines("Gl\u00fcck+1", con)
15+
16+
style_file(tmp)
17+
result <- readLines(con)
18+
expect_equal(result, "Gl\u00fcck + 1")
19+
}
20+
)
21+
})

0 commit comments

Comments
 (0)