Re: urlencode and google search query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joel CARNAT wrote:
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" ?

you can specify your encoding to google using "ie" parameter. and output encoding with "oe". google usualy uses UTF-8, that's why some single characters are encoded in two bytes.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux