CodeIgniter Forums
Allow special character in CodeIgniter [confused] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Allow special character in CodeIgniter [confused] (/showthread.php?tid=50734)



Allow special character in CodeIgniter [confused] - El Forum - 04-06-2012

[eluser]Ayu[/eluser]
Hello all,

I have problem, and not yet finished.
If i use preg_replace with PHP(no framwork CI). Its work.
but in CodeIgniter, its didn't work, I've search and do some result as: Make general UTF-8, $config['permitted_uri_chars'].
But nothing result.

Example:
Code:
$text='name';
var_dump(preg_replace('/e/', 'é', $text));

and the result is
Quote:nam�

character freak with question mark.


Anyone can help how to allow write special character and the result is

Quote:namé

Thank you very much


Allow special character in CodeIgniter [confused] - El Forum - 04-06-2012

[eluser]Aken[/eluser]
Make sure your HTML output is also set to UTF-8 with a meta tag.

Also, preg_replace() is pretty inefficient for replacing a single character. Just use str_replace for that.


Allow special character in CodeIgniter [confused] - El Forum - 04-06-2012

[eluser]Ayu[/eluser]
I've use UTF-8
Code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8">

same case.
i use
Code:
echo 'namé';

and the result's
Quote:nam�

Please, help me to solve this problem.


Allow special character in CodeIgniter [confused] - El Forum - 04-06-2012

[eluser]cPage[/eluser]
It's probably a question of browser encoding.

Try to be explicit with the browser with :

Code:
header('Content-Type: text/html; charset=utf-8');

in the top of your view before any php.


Allow special character in CodeIgniter [confused] - El Forum - 04-07-2012

[eluser]Ayu[/eluser]
i've write it before but the same result.

<?
header('Content-Type: text/html; charset=utf-8');
?>

help me please...