When I pass a string with special characters to my view, The special characters are shown as a question mark, eg:
$data['make'] = 'Quels pneus Dunlop avez-vous acheté ?';
$this->load->view("form", $data);
This looks as follows in my view:
When I type the characters directly into the HTML page they show fine. how can I fix this issue?
EDIT: The charset is already set to:&l开发者_如何学Ct;meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Using codeigniters ascii_to_entities function did the trick.
$this->load->helper('text');
ascii_to_entities($string);
Looks like it could be a charset conflict. Make your HTML charset declaration UTF8 and save your data as UTF8 in the database or text file.
In your <head>
tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
If you are using htmlentities()
to output the data var then consider specifying the character set there as well.
echo htmlentities($str, ENT_COMPAT, 'UTF-8');
Save your view page as utf8 and that will do the job
精彩评论