This was reported on IRC by zzo38
who doesn鈥檛 have a github account, so I鈥檓 opening this issue for them.
require("querystring").escape(Buffer.from([0x80,0x81]))
is expecting%80%81
but results%EF%BF%BD%EF%BF%BD
So I鈥檓 reading this as requesting support in querystring.escape
(and maybe querystring.unescape
) for raw encoding/decoding to Buffer
instances instead of always interpreting the values as UTF-8 strings.
I'm -0 on this. Calling require('querystring').escape(Bufer.from([0x80,0x80]).toString())
is not that difficult a thing to do and I'd rather not touch the existing querystring/URL code more than necessary.
@jasnell Buffer.from([0x80,0x80]).toString()
gives you 锟斤拷
, and querystring.escape
basically converts that back to <Buffer ef bf bd ef bf bd>
and then returns %EF%BF%BD%EF%BF%BD
.
I can see why one would expect Buffer.from([0x80,0x81])
to result in %80%81
, but I share the -0 stance given that it is pretty feasible to do this in userland already. (e.g. as buf.toString('hex').replace(/../g, e => `%${e}`)
)
I鈥檓 closing this as something that can be achieved in userland. If somebody disagrees, feel free to re-open or open another issue or whatever makes the most sense to you.
Most helpful comment
@jasnell
Buffer.from([0x80,0x80]).toString()
gives you锟斤拷
, andquerystring.escape
basically converts that back to<Buffer ef bf bd ef bf bd>
and then returns%EF%BF%BD%EF%BF%BD
.I can see why one would expect
Buffer.from([0x80,0x81])
to result in%80%81
, but I share the -0 stance given that it is pretty feasible to do this in userland already. (e.g. asbuf.toString('hex').replace(/../g, e => `%${e}`)
)