urlencode and google search query
| From: | Joel CARNAT | Date: | Wed, 27 Oct 2004 13:45:15 +0000 |
| Subject: | urlencode and google search query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-200448@lists.php.net to get a copy of this message | ||
Hi,
I have a submit form from where I can search things to several sites
(google, freshmeat, ...). I use PHP4/urlencode to generate the correct
query. But it seems google does not use the right encoding :(
example - query="programme télé":
********************
$engine = $_POST["engine"];
$query = urlencode($_POST["query"]);
switch($engine) {
case "google":
echo "<html><meta http-equiv=\"refresh\" content=\"0;url=http://www.google.fr/search?q=$query\"></html>";
break;
case "freshmeat":
echo "<html><meta http-equiv=\"refresh\" content=\"0;url=http://freshmeat.net/search/?q=$query\"></html>";
break;
}
********************
when I use my code, the final URL is:
http://www.google.fr/search?q=programme+t%E9l%E9
when I search "programme télé" straight from google's page, the URL is:
http://www.google.fr/search?num=20&hl=fr&q=programme+t%C3%A9l%C3%A9&btnG=Rechercher&meta=
i also tried (by hand):
http://www.google.fr/search?q=programme+t%C3%A9l%C3%A9
which is working.
how comes urlencode generates "%E9" and google generates "%C3%A9" ?
is google using some specific encoding ? any tweak to encode "the google way" ?
TIA,
Jo
PS: I'm running OpenBSD/sparc64 with Apache 1 and PHP 4 (if it matters)
--
,-- This mail runs ---------.
`------------ NetBSD/i386 --'