Hello. How can I pass a string containing the Russian text through a GET request to the script so that Russian characters do not turn into cracks? In GH, Opera and MF, everything works, but in IE, as always - no. If not difficult, give a little primerchik. Thank.

I pass a GET request like this:

$a=$_SESSION["login"]; echo urlencode(iconv("CP1251","UTF-8",$a)) 

I process a GET request like this:

 echo iconv("CP1251","UTF-8",$_GET["id"]) ; mb_internal_encoding("UTF-8"); $a = urldecode($_GET["id"]); echo " --> ".iconv("UTF-8","UTF-8",$a) ; $log = strip_tags(trim(mb_strtolower($_GET["id"]))); 

    2 answers 2

     $a = $_GET["id"]; if (!preg_match('//u', $a)) { $a = iconv("cp1251","UTF-8",$a); } echo $a; 
    • And urlencode () should be used when creating a get-request? - AseN pm
    • @Deonis, it works! I can not believe it! Thank you very much! And how did it happen? - AseN
    • If this code solves your problem, then you have an error describing the problem. - razielsd
    • @Deonis, you always help me out with these encodings ... - AseN

    Use urlencode


     <a href="./test2.php?id=<?php echo urldecode('Всем привет')?>">Привет</a> 


     <?php var_dump($_GET); 
    • Yes, it can be considered obvious, but I would like to see an example, if you can =) - AseN
    • In IE, this does not work. Squares instead of letters ... - AseN
    • one
      Why transfer from cp1251 to utf8 when sending, and when receiving again? enough: $ url = 'http: // ...? param ='. urlencode ('russian text'); when received: var_dump ($ _ GET ['param']); - razielsd
    • In IE this doesn't work either ... why? - AseN
    • Set the utf-8 encoding in the browser :) - razielsd