Diagnose a DESCRIPTION Encoding Other Than UTF-8
Source:R/diagnostics-description-fields.R
lab_encoding_utf8.RdFlags an Encoding that is anything but exactly UTF-8, which is the test
CRAN's incoming check applies. latin1 and latin2 are still legal R, but
CRAN NOTEs them as deprecated, and the comparison is case-sensitive, so a
lower-case utf-8 is NOTEd too. An absent Encoding passes.
Arguments
- path
Character. Path to the package directory. Default:
".".- verbose
Logical. Print diagnostic output. Default:
TRUE.- desc
Optional pre-parsed
DESCRIPTION, as returned bybase::read.dcf(). Defaults to reading it frompath.
Value
checktor_check_result() with passed, issues, message.
Source
Writing R Extensions,
under "The DESCRIPTION file", says a non-ASCII DESCRIPTION "should contain an
'Encoding' field"; the
incoming check
run by R CMD check --as-cran NOTEs any value but UTF-8 with "Package
encoding '...' is deprecated. Please change to UTF-8 for non-ASCII content."
See vignette("check-sources", package = "checktor") for how every check
maps to its source.
See also
checktor(), which runs this and every other check.
Examples
pkg <- example_diagnose_scenario("description_examples/encoding_utf8_bad.txt",
show_content = FALSE)
lab_encoding_utf8(pkg, verbose = FALSE)$issues
#> [1] "Encoding is \"latin1\"; CRAN's incoming check says package encoding 'latin1' is deprecated and asks for UTF-8"
unlink(pkg, recursive = TRUE)