Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7560343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:52:43+00:00 2026-05-30T12:52:43+00:00

I found a problem with some results of a search on a DB. When,

  • 0

I found a problem with some results of a search on a DB. When, some fields have extra characters like “ü”, the field return as null so it appear as null on the search. My code is like this:
the php Script

 $q=mysql_query("SELECT * FROM PRODFAR WHERE ARTI LIKE '%".$_REQUEST['search']."%'");
    while($e=mysql_fetch_assoc($q))
            $output[]=$e;

    print(json_encode($output));

    mysql_close(); 

the JSON PARSER constructor:

public class JsonParser {
    static InputStream is = null;
    static JSONObject json_data = null;
    static String result = "";

    // constructor
    public JsonParser() {
    }

    public  JSONArray getJSONFromUrl(ArrayList<NameValuePair> nameValuePairs, String url) {

        //http post this will keep the same way as it was (it's important to do not forget to add Internet access to androidmanifest.xml
        InputStream is = null;
        String result ="";
        JSONArray jArray = null;
        try{
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(url);
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();

        }
        catch(Exception e){
            Log.e("log_tag", "Error in http connection "+e.toString());
        }

        //convert response that we receive from the php file into a String()
        try{


            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
        }catch(Exception e){
            Log.e("log_tag", "Error converting result "+e.toString());
        }

        // try parse the string to a Json object
        try {
            //json_data = new JSONObject(result);
            jArray = new JSONArray(result);


        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }

        // return Json String
        return jArray;

    }    
}

any hint of how I can solve this?

update: as long as I cannot pass it with JSON, because it only admits UTF-8 characters. I think that one of the possible solutions is to convert the text through PHP into UTF-8 encoding archive, and the other is to use an alternative to JSON that supports other encodings. so I would like to try the first one. so if any know a good algorithm to covert the encoding of a text to UTF-8 using PHP will help to. Also other hints or tips of possible directions to find a solution are welcome please comment on this post any Idea is welcome

SOLVED
I solved it encoding it to UTF-8, it changed my characters like “ü” to something like u\000f, but the java editor show it as iso-8859-1 like Ü when it’s showed on the screen. The edited PHP code have the following lines after the query:

$q=mysql_query("SELECT * FROM PRODFAR WHERE ARTI LIKE '%$search1%'");
        while($e=mysql_fetch_assoc($q)){
              $e['ARTI'] = utf8_encode ( $e['ARTI'] );
              $e['DESC'] = utf8_encode ( $e['DESC'] );
              $e['PRESENT'] = utf8_encode ( $e['PRESENT'] );   
                $output[]=$e;
        }
        print(json_encode($output)); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:52:44+00:00Added an answer on May 30, 2026 at 12:52 pm

    JSON only support UTF8. So try using utf8_encode() / utf8_decode() for conversion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem, right now when I do a search like: really long
I have some code within struts.xml like: <action name=viewApplicationPDF class=com.xxx.abc.web.action.XApplicationPDFAction> <result name=success>/WEB-INF/templates/xApplication.jsp</result> </action> I
I found some problem. When i running apc_store and more times update a page
Already found this page with some helpful hints. Problem is I need to debug
I got problem with sending data in Android using httpPost. I found some example,
We have encountered a very strange class not found problem in our web app
I'am currently working on GWTs Activity-Place implementation. Now I have found problem with the
I have found a problem with use JQuery timeout, i have a page with
I have found similar questions while doing some research, but none of them really
I am trying to implement pagination in my search results with Yii. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.