From urlEncode to normal

<html>
   <head>
    <meta charset="UTF-8">
    <title>idn</title>
  </head>
<body>
<?php

require_once('idna_convert.class.php');
[SIZE="5"][COLOR="DarkGreen"]$IDN[/COLOR][/SIZE] = new idna_convert();
$serverName = $_SERVER["SERVER_NAME"];
echo "(2) " . $serverName."<br>";

[COLOR="Blue"]$IDNserverName = strcmp('xn--', substr($serverName, 0, 4)) ? 
rawurlencode($serverName) : rawurlencode([SIZE="5"][COLOR="DarkGreen"]$IDN[/COLOR][/SIZE]->decode($serverName));[/COLOR]
echo "(3) " . $IDNserverName;

?>
</body>
</html>

I have the code above at the temperal URL http://사랑.dot.kr/x-test/11.php .

If you click the link above I hope you see the word “love” in 3 ways like the following.

(1) In the url box of your browser, You can see http: //사랑.dot.kr.

The Korean word “사랑” means “love” in English.

(2) You can see “(2) xn–9i2br6o.dot.kr .”
xn–9i2br6o.dot.kr is the punyCode for “사랑” which means love in English.

(3) you can see “(3) %EC%82%AC%EB%9E%91.dot.kr .”
%EC%82%AC%EB%9E%91 is the urlCode for 사랑 which means “love” in English.

The urlCode “%EC%82%AC%EB%9E%91” is displayed because the blue line of the code above change it from korean word “사랑” to urlCode .

I like to print(echo) the korean word “사랑” instead of the punyCode(xn–9i2br6o) or the urlCode (%EC%82%AC%EB%9E%91) .

(I guess $IDN which is defined through idna_convert.class.php has the clue.

Since “echo $IDN” causes “Catchable fatal error: Object of class idna_convert could not be converted to string in” I roughly guess it’s the matter of how echo $IDN without PHP error …)