开发者

get utf8 urlencoded characters in another page using php

开发者 https://www.devze.com 2023-04-12 16:28 出处:网络
I have used rawurlencode on a utf8 word. For example $tit = \'தேனின் \"வாசம்\"\';

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.


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.


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


<?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.

0

精彩评论

暂无评论...
验证码 换一张
取 消