On ny site, my users can submit news articles and other content via forms which insert content into mysql.
When inserting text containing certain characters, it's replacing them with strange groups of characters.
Take a look, see the bits in red:
"Ibiza - the birthplace of modern dance music. 20 years on and the island remains an important catalyst for todayâ•?s hottest dance talents. This year, OceanLab, the project featuring Above & Beyond and singer/songwriter Justine Suissa spent several weeks holed up in a villa there finishing their debut album, â•?Sirens Of The Seaâ•?."
Now i know this has to do with text encoding. But I'm not sure how to overcome this.
Every time people add content to my site, I have to edit it.
I did find a function online somewhere, but it appears not to be working as it should.... or at all??
here is the function:
Code: Select all
function smarties($string)
{
/**
* ‘ 8216 curly left single quote
* ’ 8217 apostrophe, curly right single quote
* “ 8220 curly left double quote
* ” 8221 curly right double quote
* — 8212 em dash
* – 8211 en dash
* … 8230 ellipsis
*/
$search = array(
'&',
'"',
chr(212),
chr(213),
chr(210),
chr(211),
chr(209),
chr(208),
chr(201),
chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(150),
chr(133)
);
$replace = array(
'&',
'"',
'‘',
'’',
'“',
'”',
'–',
'—',
'…',
'‘',
'’',
'“',
'”',
'–',
'—',
'…'
);
return str_replace($search, $replace, $string);
}Kind regards,
Scott