haskell / HTTP

Haskell HTTP package

Home Page:http://hackage.haskell.org/package/HTTP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

urlEncode gives wrong output for non-ASCII

ethercrow opened this issue · comments

Prelude Network.HTTP> urlEncode "ололо"
"%04%3E%04%3B%04%3E%04%3B%04%3E"

while it should be "%D0%BE%D0%BB%D0%BE%D0%BB%D0%BE"

This bit me as well.

urlEncode "好" == "%59%7D"

Where in fact you should UTF-8 encode it before escaping, so that:

urlEncode "好" == "%E5%A5%BD"

Should be fixed by @batterseapower's patch - please reopen if there's any problem. I'll upload a new version with the change shortly.

urlEncode should not make any assumptions about text encoding. There is no requirement to encode the data only as utf-8. It is best if the user would select the text encoding or encode ByteString as is.

http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html