Part of the EllisLab Network
   
2 of 2
2
Problems with accents and special characters
Posted: 08 December 2008 06:08 PM   [ Ignore ]   [ # 16 ]  
Lab Assistant
RankRank
Total Posts:  225
Joined  06-04-2007

Hola, estoy fue lo que yo hice (en mis vistas y en la base de datos)

Entonces las unicas cosas que tuve que hacer:

En la base de datos:

      DB Collation: utf8_general_ci

en la vista:

<html lang=“es”>

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />

Saludos

 Signature 

http://www.asinox.net
CodeIgniter code and more.

Profile
 
 
Posted: 25 January 2009 07:22 PM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  4
Joined  01-25-2009

Hello guys! just for the record, I’m working with Spanish especial chars, and this is what I did to get it rollin. Change the values in the database.php inside your config folder like these:

$db[‘default’][‘char_set’] = “latin1”;
$db[‘default’][‘dbcollat’] = “latin1_swedish_ci”;

Then just make sure that the collation of your attributes in your db are “latin1_swedish_ci”.

And that is all!

Hope this helps someone!
Cheers! :D

Profile
 
 
Posted: 25 January 2009 07:40 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
RankRank
Total Posts:  225
Joined  06-04-2007
Andres Ledesma - 26 January 2009 12:22 AM

Hello guys! just for the record, I’m working with Spanish especial chars, and this is what I did to get it rollin. Change the values in the database.php inside your config folder like these:

$db[‘default’][‘char_set’] = “latin1”;
$db[‘default’][‘dbcollat’] = “latin1_swedish_ci”;

Then just make sure that the collation of your attributes in your db are “latin1_swedish_ci”.

And that is all!

Hope this helps someone!
Cheers! :D

Im sorry Andres but the real thing is:

$db[‘default’][‘char_set’] = “utf8”;
$db[‘default’][‘dbcollat’] = “utf8_general_ci”;

All chars wink

 Signature 

http://www.asinox.net
CodeIgniter code and more.

Profile
 
 
Posted: 26 January 2009 12:44 AM   [ Ignore ]   [ # 19 ]  
Summer Student
Total Posts:  4
Joined  01-25-2009

Well, I used “latin1” as char_set and “latin1_swedish_ci” as coll, and the accents and “ñ” worked like a charm.
smile

Profile
 
 
Posted: 26 January 2009 02:07 AM   [ Ignore ]   [ # 20 ]  
Lab Assistant
RankRank
Total Posts:  225
Joined  06-04-2007

sure!! but remember…Latin1 != “Latino” jejeej,  try to use alwasy utf8 and utf8_general_ci and in ur html file the chatset utf8

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />


smile

 Signature 

http://www.asinox.net
CodeIgniter code and more.

Profile
 
 
Posted: 26 January 2009 02:17 AM   [ Ignore ]   [ # 21 ]  
Summer Student
Total Posts:  4
Joined  01-25-2009

Excellent! Thanks for the tip, its always good to share knowledge!

Cheers! grin

Profile
 
 
Posted: 03 July 2009 07:11 PM   [ Ignore ]   [ # 22 ]  
Summer Student
Avatar
Total Posts:  10
Joined  06-18-2009

Im sorry guys but I try everything you say:

$config[‘charset’] = “UTF-8”;
$db[‘default’][‘dbcollat’] = “utf8_general_ci”;

and

$db[‘default’][‘char_set’] = “latin1”;
$db[‘default’][‘dbcollat’] = “latin1_swedish_ci”;

and no luck… in my database y try collation utf8_general_ci and utf8_spanish_ci y also try

<META HTTP-EQUIV=“Content-Type” CONTENT=“text/html; charset=ISO-8859-1”>

and

<META HTTP-EQUIV=“Content-Type” CONTENT=“text/html; charset=“UTF-8”>

and nothing Im still getting this: Huérfana instead of this Huérfana, thanks for your help!!

 Signature 

Gerardo Jaramillo
Web Aficionado

Profile
 
 
Posted: 03 July 2009 08:05 PM   [ Ignore ]   [ # 23 ]  
Summer Student
Total Posts:  4
Joined  01-25-2009

Ok, well you can try to set your database collation to “latin1_swedish_ci” instead of “utf8_spanish_ci”, and of course use the same collation un your database configuration file, like this:

$db[‘default’][‘char_set’] = “latin1”;
$db[‘default’][‘dbcollat’] = “latin1_swedish_ci”;
As you correctly did.

Or you can try utf8, but be careful to use “utf8_unicode_ci” instead of the “utf8_general_ci” that you are currently using, and you should change your config accordingly to this:

$db[‘default’][‘char_set’] = “utf8”;
$db[‘default’][‘dbcollat’] = “utf8_unicode_ci”;

Please note that the $db[‘default’][‘char_set’] value doesn’t have a hyphen (this is wrong: “utf-8”).

Try the first option or the second, both should work without any trouble, but please tell us about any further problems you might face.

Regards!

Profile
 
 
Posted: 04 July 2009 06:33 AM   [ Ignore ]   [ # 24 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3896
Joined  04-25-2008

You should check to see how the characters display via phpMyAdmin or equivalent. If they display properly, then the issue is not database coding.

It might also be worth sending the encoding in a header:

header('Content-type: text/html; charset=utf-8'); 
 Signature 

Remember the 8 Ps: Perfect Planning and Prior Preparation Prevents Piss-Poor Performance.


Not sure where to start with your project? Need some inspiration? Check out my CodeIgniter Resources thread

Profile
 
 
Posted: 04 July 2009 06:37 PM   [ Ignore ]   [ # 25 ]  
Summer Student
Avatar
Total Posts:  10
Joined  06-18-2009

I was about to reply exactly that… the fix for me was using the header tag : header(‘Content-type: text/html; charset=utf-8’);

thanks TheFuzzy0ne, JoostV and vitoco

 Signature 

Gerardo Jaramillo
Web Aficionado

Profile
 
 
Posted: 28 November 2010 09:30 AM   [ Ignore ]   [ # 26 ]  
Summer Student
Total Posts:  1
Joined  11-28-2010

SPANISH:
Tuve varios problemas similares con CI hace poco, el problema más común era que alguna data con acentos no se almacenaba correctamente en MySQL, lo cortaba en los acentos, por ejm: “frágil” lo almacenaba en MySQL como “fr”, “compañero” lo almacenaba “compa”, etc.

El problema con esto es que los archivos que contenían la data no estaban codificados en UTF8 sino en ANSI. CI funciona de mil maravillas, no hay que cambiar nada en el source de CI ni hacer trucos de configuración, el problema está en la data que están insertando/mostrando. Si están decididos a trabajar con UTF8 sigan estos consejos:

1- En el HEADER de su página, indiquen el Content-Type es UTF8:

<meta http-equiv="content-type" content="text/html; charset=utf8" /> 

2- Al cargar data en la BD, si la data viene de un archivo de texto, php o similar, asegúrense que dicho archivo está codificado en UTF8, pueden bajarse Notepad++ y seleccionar menú -> formato -> Codificar en UTF8 sin BOM.

3- Al cargar data de un formulario, asegúrense que la página de dicho formulario está en UTF8, es decir, tiene un Content-Type de UTF8.

4- Coloquen en el archivo de config “database.php” de CI:

$db['default']['char_set''utf8';
$db['default']['dbcollat''utf8_general_ci'

5- Coloquen los Collation (cotejamiento) de MySQL en “utf8_general_ci”.

6- Para que sus páginas no se muestren con caracteres raros como “frA!gil” en vez de “frágil”, codifiquen el archivo .htm o .php en UTF8 (pueden usar, como les dije, Notepad++), esto no es necesario hacerlo con los archivos de CI, sólo con los que uds generen.

Espero haber sido de ayuda.

Profile
 
 
   
2 of 2
2