mardi 25 juillet 2017

Ruby: list file names with special characters

I have a file as data/raw/sample�X�}.pdf. The file has special characters .

Now when I try to run the below code to list the file:

Dir["data/raw/*"]

It gives below output:

["data/raw/sample\357\277\275X\357\277\275}.pdf"]

i.e the special characters like � are getting converted to some octal representation like \357 . I want a ruby code that lists the exact file with special characters.

Aucun commentaire:

Enregistrer un commentaire