![]() |
Special caracters - 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: Special caracters (/showthread.php?tid=37414) |
Special caracters - El Forum - 01-09-2011 [eluser]yorvik[/eluser] Hello I am getting data from a database where I show it with echo $record->myField; For example I get this word Lindström Bengt => but this is not the way I want the word to be shown. Lindström Bengt should be => Linström Brengt In my table the word is spelled ok. But CI show some strange carracters for ö. How can I fix this. Thanks in advance! Special caracters - El Forum - 01-09-2011 [eluser]Krzemo[/eluser] Assuming you are using MySQL: mysql character set collation and http://philsturgeon.co.uk/news/2009/08/UTF-8-support-for-CodeIgniter http://www.haughin.com/2010/02/23/building-utf8-compatible-codeigniter-applications/ Special caracters - El Forum - 01-09-2011 [eluser]Nick_MyShuitings[/eluser] You can also do a php function if you get tired of bashing your head against the DB settings... run a utf8_decode on that and it should show up properly... Special caracters - El Forum - 01-09-2011 [eluser]yorvik[/eluser] I will give the utf8_decode() a try. Thanks for the advice. Edit: the utf8_decode() fixed it thank you ![]() Special caracters - El Forum - 01-09-2011 [eluser]Nick_MyShuitings[/eluser] np... I learned that after long hours of cursing when a crappy SOAP API I had to consume returned the data all weird like that. Special caracters - El Forum - 01-09-2011 [eluser]yorvik[/eluser] What I don't understand is that I need to decode utf8 like php manual says: Quote:This function decodes data, assumed to be UTF-8 encoded, to ISO-8859-1. If it is decoded my text is spelled correct. Then why do I need this utf8 char_set? Because I never had a problem like this before if worked without the CI Framework. It would be a lot of work if I have to utf8_decode() all my output? thanks Special caracters - El Forum - 01-09-2011 [eluser]Krzemo[/eluser] Have you had a chance to read http://philsturgeon.co.uk/news/2009/08/UTF-8-support-for-CodeIgniter? utf8_decode() isn't magic cure for bad design and bad code ... Special caracters - El Forum - 01-09-2011 [eluser]Nick_MyShuitings[/eluser] [quote author="Cshamoh" date="1294636525"]Have you had a chance to read http://philsturgeon.co.uk/news/2009/08/UTF-8-support-for-CodeIgniter? utf8_decode() isn't magic cure for bad design and bad code ...[/quote] 100% agreed... but it is a quick patch if you're in a bind. In my example I couldn't control the horrible design of the web-service and had to take what I got. If you control the whole project its really only a few simple steps to get UTF-8 working properly across editor, php, mysql, and then CI. Special caracters - El Forum - 01-09-2011 [eluser]yorvik[/eluser] Ok I read the article set everything ok I made some errors on my previous project where my data in my database was not converted to UTF8. Thanks for the help! |