开发者

using codeigniter - why do european characters not show properly?

开发者 https://www.devze.com 2023-02-24 02:15 出处:网络
When I pass a string with special characters to my view, The special characters are shown as a question mark, eg:

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:

using codeigniter - why do european characters not show properly?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消