resty icon indicating copy to clipboard operation
resty copied to clipboard

Resty can't handle Chinese character

Open bo-er opened this issue 2 years ago • 1 comments

Can resty support custom encoding?

bo-er avatar Dec 19 '21 05:12 bo-er

When you are creating an issue on any kind of programming website, make sure you spend a little more of your precious time to explain what your problem is and make an effort to give example cases and code blocks.

On to the subject at hand:

GET

GOLANG

resp, err := resty.New().R().Get("https://postman-echo.com/get?foo=" + url.QueryEscape("世界"))

CURL

curl -G  -H "Accept-Charset: utf-8"   https://postman-echo.com/get --data-urlencode "foo=世界" | jq

POST

GOLANG

resp, err := resty.New().R().SetBody("{foo: \"世界\"}").Post("https://postman-echo.com/post")

CURL

curl -X POST -H "Accept-Charset: utf-8" -H "Content-Type: application/json"  https://postman-echo.com/post -d  "{foo: 世界}"

From the looks of it I think you demand the client to automatically urlencode your query parameters.

Akaame avatar Dec 28 '21 21:12 Akaame