Top Poster
#1 ramon fincken 400
#2 Site admin 3
#3 Ber|Art 2
#4 braddmark 1
#5 accentmedia 1
#6 Xarzu 1
#7 pEcosespedex 1
#8 khadish 1
#9 moxxx 1
#10 nistelrock 1
[solution][howto] Convert special characters to normal chars (é to e)



Rating : 3 / 5

 
Post new topic   Reply to topic    Ramonfincken.com Forum Index -> PHP coding
Beta
Want to be notified by email when this topic gets a reply?  
View previous topic :: View next topic  
Author Message
ramon fincken
Site's programmer

Get a free globally recognized avatar
It's free!


Joined: 03 Aug 2007
Posts: 400
Location: A'dam/Diemen, The Netherlands

PostPosted: Sun Nov 15, 2009 5:38 pm    Post subject: [solution][howto] Convert special characters to normal chars (é to e) Reply with quote

How to convert

testáén
to
testaen

?

Use the force ! And use WordPress functions ..



WordPress has this lovely function called remove_accents($string); to create a "slug" which is used to create seo_friendly urls.
I've attached the functions below.

Code:
/**
 * Converts all accent characters to ASCII characters.
 *
 * If there are no accent characters, then the string given is just returned.
 *
 * @since 1.2.1
 *
 * @param string $string Text that might have accent characters
 * @return string Filtered string with replaced "nice" characters.
 */
function remove_accents($string) {..}


It relies on:
Code:
/**
 * Checks to see if a string is utf8 encoded.
 *
 * NOTE: This function checks for 5-Byte sequences, UTF8
 *       has Bytes Sequences with a maximum length of 4.
 *
 * @author bmorel at ssi dot fr (modified)
 * @since 1.2.1
 *
 * @param string $str The string to be checked
 * @return bool True if $str fits a UTF-8 model, false otherwise.
 */
function seems_utf8($str) {..}



ps: all credit goes to WordPress and bmorel for this one!

Download:
http://www.ramonfincken.com/uploads/topic_192.txt
Back to top
View user's profile Send private message Visit poster's website
Google adsense
Advertisement





PostPosted: Sun Nov 15, 2009 5:38 pm    Post subject: [solution][howto] Convert special characters to normal chars (é to e)

Advertisement
Back to top
GravityForms
Advertisement





PostPosted: Sun Nov 15, 2009 5:38 pm    Post subject: [solution][howto] Convert special characters to normal chars (é to e)

Advertisement
Gravity Forms Plugin for WordPress
Back to top
Post new topic   Reply to topic    Ramonfincken.com Forum Index -> PHP coding All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
General forums
The world of freelance
Programming
Other projects
Poll
I love gifts

Yes goodies and presents! [3]
No but I love polls ! [1]

Related google ads