Double-byte characters in querystring using PHP

I'm trying to figure out how to create personalized urls for double-byte languages.

For example, this url from Amazon Japan has Japanese characters within the querystring (specifically, the path):風の谷のナウシカ-DVD-宮崎駿/dp/B00005R5J3/ref=sr_1_3?ie=UTF8&s=dvd&qid=1269891925&sr=8-3

What I would like to do is have:風の谷のナウシカ

or even風の谷のナウシカ

be able to properly decode the $GET[name] string.

I think I have tried all of the urldecode and utf8_decode possibilities, but I just get gibberish in response.

This all works fine in a form $_POST, but I need these urls to be emailable...

EDIT: Here is the code I'm using:

<p>Original: <?= $_GET[str]; ?>

<br>Decode: <?= urldecode($_GET[str]); ?>

<br>Decode querystring: <?= urldecode($_SERVER[QUERY_STRING]); ?>


   while (list($var,$value) = each ($_SERVER)) {
      echo "$var => $value <br />";


Got it!

I needed to make sure the header was reporting:

header ('Content-type: text/html; charset=utf-8');

Once I did that, the characters were interpreted properly.

I also found this, which is a very good resource:

Have you tried reading the GET value directly? As with $_SERVER['QUERY_STRING'] or equivalent? I'm pretty sure that the urldecode() function still has some issues, even though it's supposed to work with UTF-8 since version 5.0.

This page over at has some useful comments, some specifically for Japanese cases.

Need Your Help

CSS Sprite in a fluid layout

html css css-sprites fluid-layout

I have a background image to be used for CSS sprite

How to avoid Eclipse Xdebug Error "Illegal or not full path" window

eclipse xdebug eclipse-pdt

I set up Eclipse to debug a PHP project (joomla) with XDebug.