Page 1 of 1

urlencode problem

Posted: Tue May 02, 2006 11:34 pm
by reza56
I write this code.

Code: Select all

$title = " L'étudiante";
echo htmlentities("http://www.google.com/search?q=". urlencode('"' . $title . '"'));
In Localhost Result is :

Code: Select all

http://www.google.com/search?q=%22L%27%E9tudiante%22
But In Server is :

Code: Select all

http://www.google.com/search?q=%22L%26%23039%3B%26eacute%3Btudiante%22
What is problem. I can't find any solution for this problem.

Posted: Tue May 02, 2006 11:46 pm
by feyd
character encoding scheme between the machines is different.

Posted: Wed May 03, 2006 2:07 am
by Ollie Saunders
Character encoding scheme? I can see nothing in the manual or php.ini about such a thing.

Posted: Wed May 03, 2006 3:32 am
by Maugrim_The_Reaper
Character encoding is not natively supported by PHP - it uses the mbstring library for some string functions where character encoding (usually multibyte characters) is important. You should read up on PHP, Apache, MySQL and character encoding is you are using the French language. Try playing around with default ASCII files and the french character Ç.

Posted: Wed May 03, 2006 3:44 am
by Ollie Saunders
I know what character Encoding is UTF-8, US-ASCII, Unicode, etc. etc. I just I see no mention of it in PHP; at all. Which does seem strange

Posted: Wed May 03, 2006 3:59 am
by Maugrim_The_Reaper
PHP is basically ASCII oriented - only a few functions directly refer to a character encoding as a parameter. htmlentities() does for example since it's essential in correctly entitising characters, mbstring does a lot for commonly used string functions, preg/ereg functions also have character encoding support with switches (though you need to specify a language's alpha/alnum range via numeric entities for many languages). Locale functions also manage character encoding for ctype among others.

Basically, anyone allowing multiple languages in an application (fully - i.e for usernames etc.) should be aware of all these. By default with locale still set to default of english, french á, é, etc. characters are not valid alphabetic letters in ctype_alpha() for example unless you switch the locale to "french".

I have lot's of fun since my name is non-english - Pádraic. ;) Try here - https://sourceforge.net/users/maugrim_t_r/ - my SF profile. This is a prime case where SF lies. This is not a valid UTF-8 document - it does not display the á character correctly since it is not properly encoded. Probably due to either a PHP string/entity function or something on the database side.

http://blog.quantum-star.com/index.php? ... -them.html

PHP6 will fix a lot of this...

Posted: Wed May 03, 2006 5:25 am
by Chris Corbyn
Maugrim_The_Reaper wrote:PHP6 will fix a lot of this...
Full unicode support is already added to PHP6 in CVS from what I can remember :)

Posted: Wed May 03, 2006 7:22 am
by Maugrim_The_Reaper
Release, release, release...;)

Posted: Wed May 03, 2006 11:05 am
by santosj
d11wtq wrote:Full unicode support is already added to PHP6 in CVS from what I can remember :)
Not all functions have been updated to work with the unicode, I do wish that that apprend string functions to the string variables as such, creating a string class.

$string.convert(UTF8);

for when you type casted a variable to be that of a string. Then again, you could just use Java and I like PHP better for Web stuff.