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

corrupted strings in Windows using fs #42

Closed
Leo-Lee15 opened this Issue Jan 19, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@Leo-Lee15
Copy link

Leo-Lee15 commented Jan 19, 2018

The results of the dir_ls() function are corrupted when the strings are in Chinese.

library(fs)
dir_ls()
down                                          dplyr鍖呬腑鐨刣istinct()鍑芥暟.Rmd                    
dplyr鍖呬腑鐨刣istinct__鍑芥暟.md                     EBImage鍖<85>.R                                                        
flexdashboard_鍏ラ棬.html                        flexdashboard_鍏ラ棬.Rmd                         
flexdashboard瀛︿範.Rmd                          fontlicense-open.txt                          
fullpage鍖呭垱寤簊hiny搴旂敤.R                        gapminder.gif                                                                   
gdp_dats_province.rds                         gganimate鍖呭涔<a0>.R     

The sessioninfo of my R session is the following:

sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                         
 version  R version 3.4.3 (2017-11-30)  
 os       Windows >= 8 x64              
 system   x86_64, mingw32               
 ui       RStudio                       
 language (EN)                          
 collate  Chinese (Simplified)_China.936
 tz       Asia/Taipei                   
 date     2018-01-19                    

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       source        
 clisymbols    1.2.0   2017-05-21 CRAN (R 3.4.2)
 crayon        1.3.4   2017-09-16 CRAN (R 3.4.1)
 fs          * 1.0.0   2018-01-19 CRAN (R 3.4.3)
 Rcpp          0.12.14 2017-11-23 CRAN (R 3.4.2)
 rstudioapi    0.7     2017-09-07 CRAN (R 3.4.1)
 sessioninfo   1.0.0   2017-06-21 CRAN (R 3.4.3)
 withr         2.1.1   2017-12-19 CRAN (R 3.4.3)
 yaml          2.1.16  2017-12-12 CRAN (R 3.4.3)     
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jan 19, 2018

Can you also give an example of what the filenames should look like?

@Leo-Lee15

This comment has been minimized.

Copy link
Author

Leo-Lee15 commented Jan 19, 2018

This is the original file name:

fs的测试文件.docx

While the output of the dir_ls() function is the following.

fs鐨勬祴璇曟枃浠<b6>.docx
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jan 19, 2018

Great thanks!

@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jan 19, 2018

Ok I can reproduce this, it looks like we are not properly marking strings as UTF-8 in all cases. Will work on a fix.

@jimhester jimhester closed this in b0b7a88 Jan 19, 2018

@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jan 19, 2018

Ok I believe I have found all the issues related to this, if you could please test the development version and let me know if you find any other functions that mangle the paths.

@Leo-Lee15

This comment has been minimized.

Copy link
Author

Leo-Lee15 commented Jan 20, 2018

It seems that new problems arise when using the latest development version.

library(fs)
setwd("F:\\fs_test")
getwd()
[1] "F:/fs_test"
list.files()
[1] "fs测试文件夹"         "fs的测试文件.docx"    "fs的文本文件测试.txt"
dir_ls()
Error in expand_(path) : object '_fs_expand_' not found
dir_exists(path = "fs测试文件夹")
Error in expand_(path) : object '_fs_expand_' not found
file_create(path(getwd(), "一个新文件.txt"))
Error in expand_(path) : object '_fs_expand_' not found
file_create(path(getwd(), "aaa.txt"))
Error in expand_(path) : object '_fs_expand_' not found
sessioninfo::session_info()

─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                         
 version  R version 3.4.3 (2017-11-30)  
 os       Windows >= 8 x64              
 system   x86_64, mingw32               
 ui       RStudio                       
 language (EN)                          
 collate  Chinese (Simplified)_China.936
 tz       Asia/Taipei                   
 date     2018-01-20                    

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       source                   
 clisymbols    1.2.0   2017-05-21 CRAN (R 3.4.2)           
 fs          * 1.0.0   2018-01-20 Github (r-lib/fs@b0b7a88)
 Rcpp          0.12.14 2017-11-23 CRAN (R 3.4.2)           
 sessioninfo   1.0.0   2017-06-21 CRAN (R 3.4.3)           
 withr         2.1.1   2017-12-19 CRAN (R 3.4.3)           
 yaml          2.1.16  2017-12-12 CRAN (R 3.4.3)  
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jan 20, 2018

That is not a problem with the package, you need to restart R before you try to install the new version.

@Leo-Lee15

This comment has been minimized.

Copy link
Author

Leo-Lee15 commented Jan 21, 2018

I've removed the fs package and reinstalled the development version. Everything works fine. Thanks for your nice work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment