I have a NodeJs (14 & 18) service which list and read files from the local filesystem, on IBMi or AS/400...
I use:
await fsPromises.readdir(mydir)
for to list all files of my directoryawait fsPromises.readFile(filename)
for to read the content...
For filenames without accent, there is no problem... But, when there are some french accents, I have several problems:
readdir(mydir)
return name_��.png instead of name_éè.png ... But I resolve this first problem with the encoding parameter, andreaddir(mydir, {encoding: 'binary'})
return the good name !calling
await fsPromises.readFile('name_éè.png')
orawait fsPromises.readFile('name_éè.png', {encoding: 'binary'})
causes an access exception: name_��.png: ENOENT: no such file or directory
It seems that the "encoding" option only applies to the result, and not to the filename parameter. This problem does not seem to exist on a Windows machine, but seems specific to AS/400.
Context: Software version: tested with NodeJS v 14.21.3, and OS400 V7R3
Usually it is started via a CL which contains the command
CMD(QSH CMD(&CMD)) JOB(&JOB) JOBQ(QUSRNOMAX) CCSID(1147) SPLFACN(*DETACH)
where &CMD is the path of the SH script ( node app.js &
)
and &JOB is the service's name...
I also tested it whithout the CCSID(1147) parameter, but I had the same problem... (finally, it doesn't mean anything because it's the system default...)
Any idea to resolve this ? Thanks