Joined: 03 Aug 2007 Posts: 281 Location: A'dam/Diemen, The Netherlands
Posted: Sun Nov 15, 2009 5:38 pm Post subject: [solution][howto] Convert special characters to normal chars (é to e)
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!
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