How do you URL encode parameters in Erlang?

前端 未结 8 1149
清歌不尽
清歌不尽 2020-12-31 01:17

I\'m using httpc:request to post some data to a remote service. I have the post working but the data in the body() of the post comes through as is, without any URL-encoding

8条回答
  •  情书的邮戳
    2020-12-31 01:40

    If someone need encode uri that works with utf-8 in erlang:

    https://gist.github.com/3796470

    Ex.

    Eshell V5.9.1  (abort with ^G)
    
    1> c(encode_uri_rfc3986).
    {ok,encode_uri_rfc3986}
    
    2> encode_uri_rfc3986:encode("テスト").
    "%e3%83%86%e3%82%b9%e3%83%88"
    
    3> edoc_lib:escape_uri("テスト").
    "%c3%86%c2%b9%c3%88" # output wrong: ƹÈ
    

提交回复
热议问题