Re: urlencode and google search query

From: Date: Wed, 27 Oct 2004 21:41:37 +0000
Subject: Re: urlencode and google search query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200480@lists.php.net to get a copy of this message
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.

« previous php.general (#200480) next »