I am having problems with a function fs.readdirwhen I want to get directory files. I used different encodings to avoid this, but I cannot solve it.
For example, I used this directory to try it.

Look at the last file, it has a special character and fs.readdirreturns12 - Un país con el nombre de un río.mp3
I just use this code to read the directory:
import fs from 'fs';
import {promisify} from 'util';
const readdir = promisify(fs.readdir);
const {err, names} = await readdir('path/to/dir');
Node version: node8-alpine
Is there any way to solve it?
Thanks in advance!
source
share