Re: cleaning article titles for URLs

From: Date: Tue, 27 Apr 2004 07:35:13 +0000
Subject: Re: cleaning article titles for URLs
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184733@lists.php.net to get a copy of this message
> Justin French" <justin@indent.com.au> wrote: > > I'm taking a user-supplied article title, and creating a search-engine > and user friendly URL for that article. Obviously the titles need to > be cleaned up and well-formatted (so no, urlencode() is not an option). > > Currently I'm: > - converting it all to lowercase > - replacing spaces with underscores > - removing ?,&,#,% > - removing multiple underscores > > But what I'm concerned about is other special characters, accented > characters, etc. > > - Are accented characters (eg cafè) allowed/safe in URLs? > - Would it be more appropriate to convert them down to ASCII (è > e, ü > > u, etc) -- and has any one got a routine to do this? > - Or would it be more appropriate to remove them altogether? > > > --- > Justin French > http://indent.com.au > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php Hello, Justin, As far as I understood from your post you would like to both preserve your article names user-readable and keep them URL safe. Maybe then you should like to see the RFC on the topic: http://www.faqs.org/rfcs/rfc1738.html Have a look at 2.2. URL Character Encoding Issues. The traditional method for encoding URL introduces replacing some non US-ASCII and *unsafe* characters with their corresponding hex value. Apparently this does not suit your needs for it makes the name string not as aesthetic as you want it. So just see which charcters you should encode and replace(delete) them with whatever other characters you like. The RFC explains most of the solution. Regards, Nikolay

« previous php.general (#184733) next »