Passing chinese characters as $_GET

Posted on 2007-10-07
Last Modified: 2008-09-27
I am trying to pass chinese string to a handler.php using $_GET['text'], but the result text will become ???. Is there anyway i can solve this>
Question by:jtcy
    LVL 7

    Accepted Solution

    <?php echo htmlspecialchars($_GET['text']); ?>
    LVL 29

    Assisted Solution

    Yours is a situation where occasions for problem just add layer after layer.
    It might even be the case that you don't really have a problem, that just the display is wrong.

    It will work, but you need to take written notes at each of your different tests so that you are sure to cover all the needed variations.

    You say "the result text will become ???".
    1 - Let's assume that the Chinese characters are correct in the URL (this should be easy to check). [If they were not, and if you are generating them thru php, that should be the first place to start]
    2 - You now need to know how php reads them, AND how (your program translates them in html AND your browser does display the HTML code it gets from your php program).
    I would probably do something like:
    echo "Values in the URL :<br><pre>"; print_r($_GET); echo "</pre>***<br>";
    $my_text=$_GET['text']; $my_text_1 = htmlspecialentities($my_text);
    $my_text_a = iconv ('BIG5', 'UTF-8', $my_text); //converts from BIG5 to utf8
    $my_text_a1= iconv ('BIG5', 'UTF-8', $my_text_1);
    echo "Text extracted from the URL....<br>";
    echo "<table border=1><tr><td>&nbsp;</td><td>Raw</td><td>HTML converted</td></tr>";
    echo "<tr><td>Raw</td><td>$my_text</td><td>$my_text_1</td></tr>";
    echo "<tr><td>BIG5 iconverted</td><td>$my_text_a</td><td>$my_text_a1</td></tr>";
    echo "</table>";
    Run this program, and look at display.
    1 - If one of the combination displays correctly, you're ALMOST done: take a note of the successful combination AND of the character page encoding used by your browser ("display" / "pagecode"). You have now all the elements to reproduce that successfully.
    2 - If no combination display correctly, you should first work on this encoding in the browser: is code page automatic recognition enabled (remember noting that on your paper)? is it Chinese character codes [and it seems that there is more than the BIG5 I suggested above] or UTF-8?
    Experiment with the various possible combinations (remember keeping track of what works or does not)
    3 - If still no results, lead additional experimentation in the php code, e.g. other Chinese character codes.

    LVL 29

    Expert Comment

    Hi itcy,

    waht was the result of my suggestion? how was the display?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now