I would like to generate a list of files in a directory. Some file names contain Chinese characters.
for example: [试验] .Test.txt
I am using the following code:
require 'find'
dirs = ["TestDir"]
for dir in dirs
Find.find(dir) do |path|
if FileTest.directory?(path)
else
p path
end
end
end
Running the script creates a list of files, but Chinese characters are escaped (replaced by backslashes followed by numbers). Using the example file name above, you will get:
"TestDir / [\ 312 \ 324 \ 321 \ 351] Test.txt" instead of "TestDir / [试验] .Test.txt".
How can I change the script to output Chinese characters?
source
share