urlencode problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
reza56
Forum Newbie
Posts: 1
Joined: Tue May 02, 2006 11:22 pm

urlencode problem

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

character encoding scheme between the machines is different.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Character encoding scheme? I can see nothing in the manual or php.ini about such a thing.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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 Ç.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Release, release, release...;)
santosj
Forum Contributor
Posts: 157
Joined: Sat Apr 29, 2006 7:06 pm

Post 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.
Post Reply