-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix glue encoding #81
Conversation
from FYI I stumbled upon this, while trying to construct a SQL query with |
Thanks, you are correct. I think a slightly more robust way to handle this is to add diff --git a/R/glue.R b/R/glue.R
index 472f079..f9ab287 100644
--- a/R/glue.R
+++ b/R/glue.R
@@ -227,7 +227,7 @@ as_glue.glue <- function(x, ...) {
#' @export
as_glue.character <- function(x, ...) {
class(x) <- c("glue", "character")
- x
+ enc2utf8(x)
} Also I would prefer leaving the current expectations as they are and adding an additional expectation explicitly testing for "UTF-8", e.g. |
Excellent ideas. Actually I had thought about A bit off-topic: When I run |
Thanks, looks good now! CRAN always runs tests in English locale, and unfortunately there isn't a robust way to write non-brittle tests that respect the users' non-english locale. |
👍 |
We experimented with that, but there are some cases where a given string is only translated once, even if you later switch encodings, so even doing that is not enough. |
Good to know, thanks!! |
glue()
does not always return UTF-8 encoded strings"That is strange, because there is even a test for that", you might think. Well, that test does not actually test for identical encodings, because
identical()
and by extensionexpect_identical()
do not care about encodings.So I fixed the test by explicitly testing for
Encoding()
and addedenc2utf8()
to bothglue()
andcollapse()
.