Question

I wanna make Unicode httprequest, althogh I changed my String to Unicode but there is some "?????" instead of My app name in my SQL database. ( my App name is in farsi)

 List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("dev_name", G.give_device_model()));
            params.add(new BasicNameValuePair("dev_ID", G.give_device_ID()));
            params.add(new BasicNameValuePair("follow_code", inputActivation.getText().toString()));
            params.add(new BasicNameValuePair("app_name",convert_2_unicode(msg) ));


            JSONObject json = jsonParser.makeHttpRequest(ur_register_app, "POST", params);

and this is my function for convert to Unicode:

  public String convert_2_unicode(String str){

        String string = "";
        try {
            // Convert from Unicode to UTF-8

            byte[] utf8 = str.getBytes("UTF-8");

            // Convert from UTF-8 to Unicode
            string = new String(utf8, "UTF-8");
        } catch (UnsupportedEncodingException e) {
        }

        return string;
    }

how can send proper Unicode Request?

Was it helpful?

Solution

it's finnaly solved, in JSON parser I used:

httpPost.setEntity(new UrlEncodedFormEntity(paramsHTTP.UTF_8));

instead of:

httpPost.setEntity(new UrlEncodedFormEntity(params ));

OTHER TIPS

May be there is incorrect collation set on your database or table.

https://dev.mysql.com/doc/refman/5.5/en/charset-charsets.html

You can check this with phpMyAdmin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top