Tuesday, 9 May 2017

Why French word of url cannot be parsed by Node.js V6?

I meet one issue, this url 'localhost:4020/share/Fr?chars=ECYCÉDN' with French word can NOT be parsed in Node V6.10.0, however it could be parsed correctly under Node V0.10.42.

Here are more details for my codes

  • The middleware for Express

    app.use bodyParser.urlencoded({ extended: false })
    app.use bodyParser.json({ limit: '20mb' })
    app.use bodyParser.urlencoded({ limit: '20mb', extended: false })
    
    
  • And output the chars in the above url router

    console.log(req.query.chars)

I test this server with curl 'localhost:4020/share/Fr?chars=ECYCÉDN', and the results are

  • Node v0.10.42

    {"chars":"ECYCÉDN"}

  • Node v6.10.0

    {"chars":"ECYCÃ DN"}

I want to know why this French word cannot be parsed correctly under Node V6.10.0?

I think it could be the character encode issue. However, I try to use querystring.unescape or querystring.escape of querystring, it does not work well.



via zangw

No comments:

Post a Comment