Welcome Guest, Not a member yet? Register   Sign In
charset problems!
#1

[eluser]Tomas Sundvall[/eluser]
Hello!

I have a really weird problem right now. In my page header, I set this:
Code:
<meta http-equiv="content-type" content="text/html; charset=latin1" />

The reason why I use latin1 instead of utf-8 is because all the codeigniter files are coded in ANSI, and if I set utf-8 as content type, the special Swedish chars won't work properly.

So far so good, but when I use the validation class I get this strange output "" before my own. I really can't understand why!

Does anyone have a clue?

/Tomas
#2

[eluser]jcavard[/eluser]
There is a charset setting in application/config/config.php
Code:
$config['charset'] = "latin1";
Make sure it is set to latin1 (it's UTF-8 by default).
#3

[eluser]Tomas Sundvall[/eluser]
I know, and I have changed the config to latin1, but it's still the same problem...
#4

[eluser]Crimp[/eluser]
I would insist on using UTF-8 and work from there. Convert all files to UTF-8, no BOM. Mixing and matching and patching encodings is a recipe for headaches.

You could have saved a file with another encoding when extending the Form_validation class, setting the form validation array in configs, etc., etc.
#5

[eluser]Tomas Sundvall[/eluser]
So you think converting all the standard CI files to utf-8 is a good idea? Do you know if there is any program that could do that automaticly? I think it's a little bit odd that all the CI files are coded in ANSI, but the standard charset is utf-8, does anyone knows why?

/Tomas
#6

[eluser]RS71[/eluser]
try

Code:
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
#7

[eluser]Crimp[/eluser]
Yes, I thnk it's a very good idea. You rule out potential problems. I use BBEdit. With that, you can make a Text Factory that converts all files with one click. (But your ref. to ANSI makes me believe you are on windows.)

I think the ANSI part happened on your system. If you download CI, it is in my experience correctly encoded in UTF-8. You could try downloading again or checking out the SVN.

The suggestion above is also correct, of course. But I would use UTF-8, even if iso-8859-1 covers swedish.
#8

[eluser]metamorpher[/eluser]
I've tried saving data via form input using utf-8 using special chars from spanish language and it just stores question marks... I'm using
Code:
$this->input->post
... and my db collation were utf-8 during the test...

I think something is not parsing well... I'm back on iso-8859-1 until someone could give a better answer Tongue
#9

[eluser]ayukawaa[/eluser]
[quote author="metamorpher" date="1234985374"]I've tried saving data via form input using utf-8 using special chars from spanish language and it just stores question marks... I'm using
Code:
$this->input->post
... and my db collation were utf-8 during the test...

I think something is not parsing well... I'm back on iso-8859-1 until someone could give a better answer Tongue[/quote]

Yes, same here. With spanish chars in input boxes and having all set to utf-8 (mysql databases and tables, html head, CI charset and database), all goes wrong after 2 days of trials (even tried Mysql4 and Mysql5).

BUT, using CI and Mysql in latin1 works fine with spanish chars from the first time!!!

So, I also think there is something wrong with CI and utf-8.

*_*
#10

[eluser]metamorpher[/eluser]
Nop... Nothing is wrong. I figured it out... This is how your database config file should look like if you're going to work with latin characters:

Code:
$db['default']['char_set'] = "iso-8859-1";
$db['default']['dbcollat'] = "latin1_general_ci";

you MUST use latin1_general_ci collation in your database tables if you don't want to translate later everything into UTF-8...


AND

use active record functions from CI, like insert, or update, don't use directly db->query, or you'll have to add slashes and this kind of stuff gaining extra lines and extra-useless bytes




Theme © iAndrew 2016 - Forum software by © MyBB