CodeIgniter Forums
Problems with accents and special characters - 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: Problems with accents and special characters (/showthread.php?tid=9857)

Pages: 1 2 3


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]CARP[/eluser]
Hi guys
I've been developing a CI app, and now I'm facing some implementation/testing problems
It is about accents and some special spanish characters like Ñ

- My config/database.php has this value
Code:
$db['default']['dbcollat'] = "utf8_general_ci";

- My database and tables were created as "utf8_general_ci"

When I add a new record to the table, with an accent, The record gets saved, but it looses all the characters after the accent (including the accented char.)

Also, the special characters aren't stored.

What should I change? Both, database.php and my db/tables are using the same coll.

EDIT: Can this be generating some conflict?
Code:
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />


Thanks a lot in advance for any help you can give me


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]marcoss[/eluser]
Hey, un argentino! Te respondo en cordobé Tongue

El juego de caracteres debe ser siempre el mismo, si tenes seteado el "content-type" en iso-8859-1 y el contenido a mostrar está en UTF-8 vas a tener problemas de visualización.

Igualmente lo que mencionas parece ser un problema a la hora de guardar los datos en la base de datos, fijate que los archivos PHP que están procesando la data estén en UTF-8 también y que no estés corriendo ninguna función que modifique la cadena de texto antes de guardarla en la base de datos.


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]CARP[/eluser]
[SPANISH]
Hola compatriota!
Asi es, el problema es al guardar la info, si guardo en el registro "carámba", solo se graba "car". No entendi a que te referis con que los archivos que esten procesando la data esten en UTF-8...
Los nombres de los controladores, modelos, y vistas, no los tengo con caracteres extraños (si es eso a lo que te referis)
Y ademas, no tengo ninguna funcion que modifique la data que posteo. Del formulario va al controlador, y del controlador al modelo, sin nada que lo procese en el camino

[ENGLISH]
Hi marcoss!
You're right, the problem is when saving the info. If I post "carámba", it only saves "car". I didn't understand what you mean with "Check that the php files that process the data are also in UTF-8...
The filenames of controllers, models, and views doesn't have strange characters (if this is what you mean)
And by the way, I don't have any function that modifies the posted data. I post the form fields to the controller, then send them to the model, and there's nothing in the middle that process that info

Gracias!/Thanks!


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]marcoss[/eluser]
By UTF-8 encoded files, i mean the files must be saved using that character set. What IDE/editor are you using?


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]CARP[/eluser]
Dreamweaver 8 on WinDorcha XP...


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]marcoss[/eluser]
The problem is DW then Tongue

Make sure every document is on UTF-8, while you are on the code view, press Ctrl+J, go to Title/Encoding and select Unicode(UTF-8) from the encoding drop-down menu.


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]CARP[/eluser]
Ouch... argggh
I tried your tip. I've not tried adding data to db yet, but so far I'm getting this little black symbols in the html, lol... this is going 2 ruin my weekend

http://img525.imageshack.us/my.php?image=sshot1hy9.jpg


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]Seppo[/eluser]
If that's the problem, just htmlentities it =)
Luckily all spanish characters are escaped via html entities
I though it wasn't saving OK into the database...

-Edit- post nº 700 =)


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]marcoss[/eluser]
If that's the data already in the database (which based on your explanation is incorrectly encoded) and you have now fixed the files encoding, it's normal to have those symbols, once you have all your data in UTF-8 you won't see that again.

Regarding htmlentities, don't use it, it's not portable. What you can do if you want to force the data entered in the database to be UTF-8 encoded, use utf8_encode() on it. Always keep your data in the same charset, choose one and stick to it.

p/d: Otro argentino!


Problems with accents and special characters - El Forum - 07-10-2008

[eluser]Seppo[/eluser]
Somos varios, che...

I don't think the data is incorrectly encoded at all... I believe it's storing properly into the database, and the problem is when it's displayed in a website... I don't understund why you sayd it is not portable... as a matter of fact, html entities exists for that purpose