1

I've a basic question in PHP:

I've 2 files: An HTML form with a Textarea and a PHP file. All I want is to print the text the user types after submit is pressed. It all goes well when only English characters are typed but I get gibberish when I type Arabic or Chinese for instance. Is there a way to display all the characters?

Here is the code of the PHP file:

<?php
     $txt = $_GET['toTranslate'];
     echo $txt;
?>
2
  • Try to search on this site (stackoverflow.com/questions/1210863/…)
    – lg.
    Dec 28, 2009 at 11:55
  • 62676857673B675B5B663B204668706174753B 62676857673B675B5B663B204668706174753B 62676857673B675B5B663B204668706174753B 62676857673B675B5B663B204668706174753B 62676857673B675B5B663B204668706174753B 62676857673B675B5B663B204668706174753B 62676857673B675B5B663B204668706174753B
    – jest
    Sep 7, 2010 at 19:19

3 Answers 3

6

Please try to add

header('Content-Type: text/plain; charset=UTF-8');

or Add set as html and set

echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
echo $txt;
0

You have to use unicode encoding in your pages and scripts.

0

Make sure the page with the form and the page with the output use the same character set (UTF-8 explicitly set with header() is the safest choice). By default PHP would return exactly what it receives, no matter what character set it is, unless you do some manipulation with that text string (in this case check out the multibyte string functions).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.