-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correctly parse non-ASCII characters of R files in Windows (#532)
* add supports for nonASCII chars in roxygenize * ensure write UTF-8 rd files
- Loading branch information
Showing
7 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
context("nonASCII") | ||
|
||
test_that("can generate nonASCII document", { | ||
test_pkg <- temp_copy_pkg('testNonASCII') | ||
on.exit(unlink(test_pkg, recursive = TRUE)) | ||
|
||
expect_output(roxygenize(test_pkg), "printChineseMsg[.]Rd") | ||
expect_true(file.exists(file.path(test_pkg, "man", "printChineseMsg.Rd"))) | ||
|
||
cnChar <- readLines(file.path(test_pkg, "man", "printChineseMsg.Rd"), encoding = "UTF-8") | ||
|
||
# Because the parse in testthat::test don't specify encoding to UTF-8 as well, | ||
# so we have to use unicode escapes. | ||
expect_true(any(grepl("\u6211\u7231\u4e2d\u6587", cnChar))) | ||
expect_true(any(grepl("\u4e2d\u6587\u6ce8\u91ca", cnChar))) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Package: testNonASCII | ||
Title: Test no change to Collate when there are no @includes | ||
License: GPL-2 | ||
Description: | ||
Author: Shrektan <shrektan@126.com> | ||
Maintainer: Shrektan <shrektan@126.com> | ||
Encoding: GB2312 | ||
Version: 0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This script is intended to be saved in GB2312 to test if non UTF-8 encoding is | ||
# supported. | ||
|
||
#' 中文注释 | ||
#' | ||
#' @note 我爱中文。 | ||
printChineseMsg <- function() { | ||
message("我是GB2312的中文字符。") | ||
} |