Search code examples
javajsonandroid-studioutf-8persian

Show incorrect data for persian UTF8 in JSON in Android Studio


I am trying to get Persian (UTF8) data from SQL Server with JSON in Android Studio, But this give me incorrect type.

for example for "ظزرظیریذرطب" show ظزرظیریذرطب

and I use SQL Server 2014 and my database collation is Arabic_CI_AS

Thanks


Solution

  • I found the solution for this problem, in java IntelliJ (web server) use this code:

     jsonObject.put("Category", URLEncoder.encode(rs.getString("Category"),"UTF-8"));
    

    and in android studio use this code:

    u.setProject(URLDecoder.decode(jsonObject.get("Project").toString(),"UTF-8"));