0

I keep getting the error above (title) when I try to make a HTTP-request to a server with a special character (the character 'å'). I have tried to call:

_login = URLEncoder.encode(_login, "utf-8");

But I still get exception. If I try to change the URL it works fine. Seems that it happends for whatever URL I try if it has special characters. Like for example http://www.ål.no.

Anyone know about a work-around? One way could of course be to use the IP-address. But I would rather avoid that.

Thanks for any help!

Some of the source code:

    private String _login =        "http://www.ål.no";

    HttpClient httpclient = new DefaultHttpClient();

    try {
        _login = URLEncoder.encode(_login, "utf-8");
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    HttpPost httppost = new HttpPost(_login);

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

    //nameValuePairs.add(new BasicNameValuePair("Mail", this.Email));
    //nameValuePairs.add(new BasicNameValuePair("Password", this.Password));


    try
    {
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        BasicHttpResponse response = null;

        try
        {
            response = (BasicHttpResponse) httpclient.execute(httppost);
        }
        catch (ClientProtocolException e)
        {
            System.out.println("BasicHttpResponse");
            e.printStackTrace();
        }
}

EDIT: Found a work around. Used Firebug to dig a little deeper. According to Firebug the server has another name when communicating (as far as I can see). This name does not contain any special characters and I successfully managed to communicate with the server using my application. Thanks for all help! :)

Araw
  • 2,410
  • 3
  • 29
  • 57
  • Not sure if this is the same issue, but check out this question: http://stackoverflow.com/questions/1133424/what-are-the-valid-characters-that-can-show-up-in-a-url-host – Marc Bernstein May 21 '13 at 17:34

1 Answers1

0

I think I understand what you're asking for. Here is a link to a list of special characters that the URL will identify.

http://www.degraeve.com/reference/urlencoding.php

If thats not what you need let me know.

to save you time, the character you're searching for is %E5

IrishWhiskey
  • 339
  • 5
  • 27