Skip to content

dir_ls() returns unreadable output for chinese characters #381

@s609078902

Description

@s609078902

I'm using fs::dir_ls() to get excel file paths under a directory main_path, but since there are Chinese characters in the file paths, I get an unreadable output, I think it's maybe related to encoding issues:

main_path <- '../../raw_data/2022-01-10/'
file_paths <- fs::dir_ls(main_path, regexp = ".xlsx") 
file_paths

Out:

../../raw_data/2022-01-10/閽㈤搧_鐒︾偔_浠峰樊_鐒︾偔J2201DCE鐒︾偔J2205DCE_涓诲姏_2022-01-10.xlsx
../../raw_data/2022-01-10/閽㈤搧_鐒︾偔_浠峰樊_鐒︾偔J2201DCE鐒︾偔J2209DCE_2022-01-10.xlsx

While list.files(path = main_path, pattern ='.xlsx') returns file names correctly:

[1] "甘其毛道库提价含税焦煤A23V2606SG85JM焦煤JM2201DCE_2022-01-10.xlsx"           
[2] "甘其毛道库提价含税焦煤A23V2606SG85JM焦煤JM2205DCE_2022-01-10.xlsx"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions