Passing chinese characters as $_GET

Posted on 2007-10-07
Medium Priority
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
  • 2

Accepted Solution

bdichiara earned 1000 total points
ID: 20030342
<?php echo htmlspecialchars($_GET['text']); ?>
LVL 29

Assisted Solution

fibo earned 1000 total points
ID: 20033508
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

ID: 21011474
Hi itcy,

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

809 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