Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot parse and display non-utf8 characters read from an http request
    primarykey
    data
    text
    <p>I'm using Java to parse this request </p> <p><a href="http://ajax.googleapis.com/ajax/services/search/web?start=0&amp;rsz=large&amp;v=1.0&amp;q=rz+img+news+recordid+border" rel="noreferrer">http://ajax.googleapis.com/ajax/services/search/web?start=0&amp;rsz=large&amp;v=1.0&amp;q=rz+img+news+recordid+border</a></p> <p>which has as a result this (truncated for the sake of brevity) JSON file: </p> <pre><code>{"responseData":{"results": &lt;...&gt; "visibleUrl":"www.coolcook.net", "cacheUrl":"http://www.google.com/search?q\u003dcache:p4Ke5q6zpnUJ:www.coolcook.net", "title":"مطبخ مطايب - كباب الدجاج والخضار بصلصة الروب", "titleNoFormatting":"مطبخ مطايب - كباب الدجاج والخضار بصلصة الروب","\u003drz+img+news+recordid+border"}}, &lt;...&gt; "responseDetails": null, "responseStatus": 200} </code></pre> <p>My problem lies in the arabic characters returned (which could be any non-unicode for that matter). I tried to convert them back to unicode using something like:</p> <pre><code>JSONArray ja = json.getJSONObject("responseData").getJSONArray("results"); JSONObject j = ja.getJSONObject(i); str = j.getString("titleNoFormatting"); logger.log("before: " + str); // this is just my version of println enc_str = new String (str.getBytes(), "UTF8"); logger.log("after: " + enc_str); </code></pre> <p>However, both the 'before' and 'after' results are the same: a set of ????'s, regardless of whether I output them in the server log file or in an HTML page. Is there another way to get back the arabic characters and output them in a webpage?</p> <p>Does JSON have any supporting functionality for this sort of problem perhaps in order to read the non-utf characters straight away from the JSONObject?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload