android httpclient and utf-8

后端 未结 1 1932
南旧
南旧 2020-12-30 17:56

I\'m trying to connect to a webservice where my querysting holds some data. The bad thing is that this data contains utf-8 charcters, which renders a problem.

If I s

相关标签:
1条回答
  • 2020-12-30 18:26

    I think you want a URL encoded query string. If so, use:

    String query = "?param=value";
    String host = "http://my.host.name.com/";
    String encodedUrl = host + UrlEncoder.encode(query,"utf-8");
    

    The basic idea is that you only want to encode the query string, not the host name or protocol.

    0 讨论(0)
提交回复
热议问题