CodeIgniter Forums
Spanish in array not displaying correctly on page - 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: Spanish in array not displaying correctly on page (/showthread.php?tid=17743)



Spanish in array not displaying correctly on page - El Forum - 04-14-2009

[eluser]RJ[/eluser]
Hello,

Below is the Spanish array I am using, attached to the post is a screen shot of the result. Page is UTF-8, Spanish characters display properly in the text, just not when passed through this array. Any thoughts how to fix?

Code:
$list = array(
                    'AU'=>'Australia',
                    'BR'=>'Brasil',
                    'DE'=>'Alemania',
                    'FR'=>'Francia',
                    'MX'=>'Méjico',
                    'NL'=>'Países Bajos',
                    'UK'=>'Reino Unido',
                    'US'=>'Estados Unidos de América');



Spanish in array not displaying correctly on page - El Forum - 04-14-2009

[eluser]SomeFunkyDude[/eluser]
Definitely an encoding issue, I'm not sure at what point it's getting mixed up, but are you able to use html entities for the special characters? http://www.w3schools.com/tags/ref_entities.asp

Joel on Software has a good article btw about encodings in case you ever have trouble sleeping http://www.joelonsoftware.com/articles/Unicode.html


Spanish in array not displaying correctly on page - El Forum - 04-14-2009

[eluser]RJ[/eluser]
@SomeFunkyDude
Tried the htmlentities, this function only allows string, not array. However, I used your link, replaced text with the appropriate code.. and wallah! Looks good, thank you!!


Spanish in array not displaying correctly on page - El Forum - 04-27-2009

[eluser]alditis[/eluser]
Hello!!!
Another solution.

codeigniter/system/application/config.php
Code:
$config['charset'] = "UTF-8";

codeigniter/system/application/views/you_view.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;My Title&lt;/title&gt;    
&lt;/head&gt;
&lt;body&gt;
...

Try it.