0
에서 Express.JS를 사용하여 Express가 UTF8 문자를 읽으면 Express가이 요청 경로 (/wiąz.txt
)를 /wiÄz.txt
으로 읽음으로써 /wiÄz.txt doesn't exist
이되지만 wiąz.txt
이 존재합니다. 요청 경로에서 utf8 문자를 읽을 수 있습니까?노드
var express = require('express');
var fs = require('fs');
var app = express();
app.set('etag', false);
app.set('x-powered-by', false);
app.route('*').all(function(req, res) {
res.set('Content-Type', 'text/plain');
try {
var file = fs.readFileSync('.' + req.path, 'utf8'); // req.path starts always with /, the result is ./FILE
res.send(file);
} catch (e) {
res.send(req.path + " doesn't exist");
}
});
app.listen(80, function() {
console.log('HTTP Server is now running on port 80');
});
문제의 코드를 게시 할 수 있습니까? –
완료. 다시 봐라. –
'fs.readFileSync ('+'decodeURIComponent (req.path) + '. txt', 'utf8')' –