Re: urldecode problem :(
| From: | Seairth Jacobs | Date: | Fri, 06 Jun 2003 13:48:53 +0000 |
| Subject: | Re: urldecode problem :( | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-150491@lists.php.net to get a copy of this message | ||
"Rosen" <rosen@pernikinfo.com> wrote in message
news:20030606121758.10269.qmail@pb1.pair.com...
> HI,
> I'm using "urldecode" function to decode string from
> "getenv("QUERY_STRING");", but part of
> it is in cyrrilic (windows-1251) charset.
>
> I have following code:
>
>
$a="%D1%81%D1%87%D0%B5%D1%82%D0%BE%D0%B2%D0%BE%D0%B4%D0%BD%D0%B0+%D0%BA%D1%8
> A%D1%89%D0%B0";
> $b="%d1%ee%f4%f2%f3%e5%f0";
>
> echo "a=" . urldecode($a);
> echo "<br>b=" . urldecode($b);
>
> On the second string it works correctly, but on first it don't.
> These two vars are getted from two different pages ( as refferers ).
> I think the problem could be in encoding used in two pages.
When I run the code without setting a charset (defaulting to UTF-8), I get
back the following:
a=?????????? ????
b=????ody>
When I run the code setting the charset to windows-1251, I get:
a=????µ????????????° ??????°
b=???????
I'm guessing you want "a" from the first one and "b" from the second one.
In which case, you are correct. Two different character encodings are being
URL encoded. You could convert the first string using:
convert_cyr_string(mb_convert_encoding(urldecode($a), 'ISO-8859-5',
'UTF-8'), 'i', 'w')
--
---
Seairth Jacobs
seairth@seairth.com