Reputation: 5417
I'm using a simple form to write string to database, but the curly quotes (on retrieval) are being displayed as special characters.
So far I have tried changing the table collation to UTF-8 as well as using the CodeIgniter Typography class:
1. alter table test.vocab convert to character set utf8 collate
utf8_unicode_ci;
2. $this->load->library('typography');
$data['item'] = $this->typography->auto_typography($data['item'], FALSE);
This hasn't helped, though. Here's what the output looks like:
If needed I'll post more code. Please help.
Upvotes: 0
Views: 282
Reputation: 5417
Thank you everyone, but it seems like what I needed was the mb_convert_encoding()
function:
$i['item'] = mb_convert_encoding($i['item'], 'HTML-ENTITIES', 'UTF-8');
Many thanks for taking out the time for commenting or answering.
Upvotes: 2
Reputation: 3962
I had a similar issue with a migrated DB. Turned out I needed to convert 'UTF-8' to 'Windows-1252'.
I found out by running the code below and checking which combination looked right:
$html = 'Your HTML here';
$charsets = array(
"UTF-8",
"ASCII",
"Windows-1252",
"ISO-8859-15",
"ISO-8859-1",
"ISO-8859-6",
"CP1256"
);
foreach ($charsets as $ch1) {
foreach ($charsets as $ch2){
echo "<h1>Combination $ch1 to $ch2 produces: </h1>".iconv($ch1, $ch2, $html);
}
}
Upvotes: 0