-
Notifications
You must be signed in to change notification settings - Fork 286
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
read_csv
can't recognize chinese file path on R 3.5.0
#834
Comments
This is due to the change of the behavior of R 3.4.4 on Windows 10: Encoding(normalizePath("~/鬼"))
#> [1] "unknown" R 3.5.0 on Windows 10: Encoding(normalizePath("~/鬼"))
#> [1] "UTF-8" The release note says:
so this seems intentional and unlikely to be reverted. Rather, I feel it's not robust that readr naively assumes the path is already encoded in the native locale; instead, path should be explicitly converted to the native locale before passed to |
I'm not sure if I have the same problem as in this issue: the I create a file: library(readr)
Sys.setlocale(locale = "Lithuanian")
dir.create("C:/data/medž/", recursive = TRUE)
write.table(x = iris, file = "C:/data/medž/data.txt") And the code fails to read it: read_file("C:/data/medž/data.txt") Fails with the message:
|
Yes, the same problem. |
I see this issue is closed but after installing the latest version of readr from github the problem still occurs, at least on my system (Windows 10, R 3.5.1) Question: Will the fix you are working on in readr also work for .rds (and perhaps .rda?) files?
|
No, Lines 18 to 20 in 3715a2d
But, I think the second one should work.
Could you show the result of this code? Is this already garbled? normalizePath("Z:/GitHub/radiant.data/萼片长/diamonds_萼片长.rds") |
Thanks for the response @yutannihilation. Is there a work-around you could suggest to load .rda or .rds files with Chinese, Russian, etc. characters in R 3.5.1 on Windows? RE the read_csv issue, as you can see below
I also tried using Rstudio's import data interface but that gives similar errors |
Hmm, curious... Considering that garbling happens even with I suspect this won't happen on Windows with CJK locale, which I use, so it may be difficult for me to investigate... Anyway I'll have a look tomorrow. |
Good news or bad news, this happens on my Windows, but the error is slightly different: saveRDS(iris, file = "萼片长.rds")
#> Error in gzfile(file, mode) : cannot open the connection
#> In addition: Warning message:
#> In gzfile(file, mode) :
#> cannot open compressed file '萼片<U+957F>.rds', probable reason 'Invalid argument' The reason Anyway, I'll file a new issue. Sorry for keeping discussing on the closed issue. |
Ah, for a workaround, I guess you can rename or copy the file: tmp_rds <- tempfile(fileext = ".rds")
file.rename("Z:/GitHub/radiant.data/萼片长/test_萼片长.rds", tmp_rds)
readr::read_rds(tmp_rds) |
Thanks @yutannihilation! |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
The text was updated successfully, but these errors were encountered: