erlang轉化中文爲url

今天使用http get 方法時,參量中有中文而致使出錯。app

例如http://abc.com/abc?arg=中文,在erlang使用http:request方法失敗。post

後來查了url的規範,url中要使用ascii字符,從而寫了下面的方法:url

lists:append([io_lib:format("%~.16B", [E]) || E <- binary_to_list(unicode:characters_to_binary("中文"))])。

上面轉化的字符追加到url末尾就能夠了。code

使用post方法能夠參考:orm

how to support chinese in http request body? erlangblog

相關文章
相關標籤/搜索