Some unicode characters do not get parsed
rvypandey opened this issue · comments
Hi team,
I'm using postman to send payload. I have some escaped unicode characters in the payload (example: \u0005).
The problem: Some escaped unicode characters are not unescaped. For example, if my payload is: { 'someKey': 'some\u0005value' }, then the output of this code:
// configure app to use bodyparser
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use((req, res, next) => {
console.log(req.body); // print payload
next();
});
is: { someKey: 'some\u0005value' }
Whereas, if I send some other unicode characters (example: \u2551), then the output is: { someKey: 'some║value' }
, or { someKey: 'some╪value' }
in case of \u256A.
I would like to know how I can handle this scenario and get body parser to parse characters like \u0005 as well.
Thanks,
Ravi Pandey
This is just how console.log
is displaying the 0x05 character in order not to mess with your terminal output. Use something else to display the body that will not display 0x05 as \u0005
.
Example without this module for the console.log
behavior:
$ node -e 'console.log({ someKey: "some\u0005value", otherKey: "other\u2551value" })'
{ someKey: 'some\u0005value', otherKey: 'other║value' }