-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plumber() and Plumber$new() will read source file as UTF-8 encoded #312
Conversation
Codecov Report
@@ Coverage Diff @@
## master #312 +/- ##
=========================================
Coverage ? 90.04%
=========================================
Files ? 25
Lines ? 1145
Branches ? 0
=========================================
Hits ? 1031
Misses ? 114
Partials ? 0
Continue to review full report at Codecov.
|
YES! Use UTF-8, or we can't be friends. Perhaps in knitr 2.0 and rmarkdown 2.0, I'll just remove the |
@yihui Do you think it's a good idea remove the argument and just force UTF-8? |
At least, it’s a good idea to me, actually. :P |
@schloerke Yes. That is what I have been doing in bookdown (since 2016) and blogdown (2017). In future packages, I'll always do this. The |
@shrektan Mind removing it from the args and adding it as a global package variable w/ comment to this PR? (Feel free to copy from below) # Hard code UTF-8 file encoding
# Removes encoding headache at minor cost of setting encoding in editor
# https://github.com/trestletech/plumber/pull/312
utf8Encoding <- "UTF-8"
plumb <- function(file, dir = "."){
# ...
x <- source(entrypoint, encoding = utf8Encoding)
# etc...
} |
798ca94
to
731704e
Compare
@schloerke I have removed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. Should be last round of review
Thank you for the test file!
…contain non-ASCII characters
127f042
to
1b19e3a
Compare
@schloerke I've made the changes you requested and add a NEWS file (I made a forced-push in order to have a clean history). Can it be merged? It's very inconvenient to maintain/edit the file as encoding other than UTF-8. Moreover, it's consistent with shiny, which forces the UTF-8 encoding in the very early stage.
In addition, there's a minor issue about using
|
Related to #296
DESCRIPTION
R uses the encoding "unknown" or "native" when reading text files by default. However, the fact that the default encoding varies (not UTF-8) on Windows, leads to a big headache for our multiple-bytes charset users on Windows, which is we have to store the source file as the native encoding in order to use plumber.
Thanks to the great work of RStudio (especially, @yihui), the common practice of handling this issue is to read the file as UTF-8 encoding by default(may provide a param "encoding" allowing users to change) and this PR is going to address this.
WHAT THIS PR DOES?
encoding
forplumber()
andPlumber$new()
As mentioned in #296, there's another issue that the function input should be marked as UTF-8, which I would like file another PR after this being merged.
Thanks.