Why can't the French word url be parsed by Node.js V6?

I meet one problem, this url 'localhost:4020/share/Fr?chars=ECYCÉDN'

with French word cannot be parsed in Node V6.10.0

, however it can be parsed correctly in Node V0.10.42

.

Here is more details on my codes

  • Secondary software for Express

    app.use bodyParser.urlencoded({ extended: false })
    app.use bodyParser.json({ limit: '20mb' })
    app.use bodyParser.urlencoded({ limit: '20mb', extended: false })
    
          

  • And output chars

    to the above router URL

    router = express.Router()
    router.get '/share/:lang', (req, res, next) ->
         console.log(req.query.chars)
    
          

I am testing 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"}

Express version 4.15.2

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

I think it might be a character encoding issue. However, I'm trying to use querystring.unescape

or querystring.escape

querystring

, it doesn't work.


Update

When I try to output console.log(JSON.stringify(req.query))

in the router '/share/:lang'

, the result is {"chars":"ECYCÃ DN"}

and the length chars

is 8

.

+3


source to share





All Articles