get utf8 urlencoded characters in another page usi

2019-08-18 16:56发布

I have used rawurlencode on a utf8 word. For example

$tit = 'தேனின் "வாசம்"';
$t = (rawurlencode($tit)); 

when I click the utf8 word ($t), I will be transferred to another page using .htaccess and I get the utf8 word using $_GET['word'];

The word displays as தேனினà¯_"வாசமà¯" not the actual word. How can I get the actual utf8 word. I have used the header charset=utf-8.

标签: php utf-8
3条回答
别忘想泡老子
2楼-- · 2019-08-18 17:37
<?php
$s1 = <<<EOD
தேனினà¯_"வாசமà¯"
EOD;
$s2 = <<<EOD
தேனின் "வாசம்"
EOD;

$s1 = mb_convert_encoding($s1, "WINDOWS-1252", "UTF-8");

echo bin2hex($s1), "\n";
echo bin2hex($s2), "\n";
echo $s1, "\n", $s2, "\n";

Output:

e0aea4e0af87e0aea9e0aebfe0aea9e0af5f22e0aeb5e0aebee0ae9ae0aeaee0af22
e0aea4e0af87e0aea9e0aebfe0aea9e0af8d2022e0aeb5e0aebee0ae9ae0aeaee0af8d22
தேனின��_"வாசம��"
தேனின் "வாசம்"

You're probably just not showing the data as UTF-8 and you're showing it as ISO-8859-1 or similar.

查看更多
Anthone
3楼-- · 2019-08-18 17:45

Did you use rawurldecode($_GET['word']); ? And do you use UTF-8 encoding for your PHP file?

查看更多
等我变得足够好
4楼-- · 2019-08-18 17:50

Was my comment first, but should have been an answer:

magic_quotes is off? Would be weird if it was still on in 2011. But you should check and do stripslashes.

查看更多
登录 后发表回答