CodeIgniter Forums
Problem with accents - 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: Problem with accents (/showthread.php?tid=37544)



Problem with accents - El Forum - 01-13-2011

[eluser]caperquy[/eluser]
Hello
I have the following problem : within my controller I read a data from my database, let say écologie which I put into a variable $a.
When I echo $a (echo "value of a : $a <br />"Wink I get écologie which is exactly what I expect.
Now I want to replace the first character with e (no accent)
I thefore catch that character with the instruction $car1=substr($a,0,1);
If I echo $car1 (echo "value of car1 : $car1 <br />"Wink I do not get é as expected but rather an unreadable character (�)
I suspect a problem with the character sets but I cannot find where.
Could someone give me a clue ? Thanks in advance
CapErquy


Problem with accents - El Forum - 01-13-2011

[eluser]tomcode[/eluser]
PHP functions like substr() are only safe to use for ASCII chars, have a look at Multibyte String