Welcome Guest, Not a member yet? Register   Sign In
UTF-8
#11

[eluser]Tanax[/eluser]
[quote author="Mackstar" date="1238087713"]My Advice when working in another language is to go completely UTF-8,

rebuild your mysql tables with the collation utf8_general_ci and all fields to be so also.. The you just add the lines to your db config and it should get the data out of the database correctly.

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

But in your case you dont know if it is the database data or the page parsing that is wrong.

If you have <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> in your html it is being set somewhere in your CI app, check your headers/footers, or search for ISO-8859-1 in your app to find the culprit.

You could try to juggle the char encoding selection in your browser and see if you get the hoped for output, in which case the meta tag may well be your culprit.


If you did want to play with your db connection you could try

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

I do a lot of development in Japanese and have found a strict utf-8 only environment has made things much easier.

Best of luck[/quote]

Code:
$db ['default'] ['char_set'] = "latin1";
$db ['default'] ['dbcollat'] = "latin1_swedish_ci";

Worked great for me!
Not sure if UTF-8 would be better. This works, so I'm happy!

Thanks for the help! And also for the info!
#12

[eluser]Mackstar[/eluser]
Glad it worked! But if you ever have multilingual content (particularly double byte content)then you will probably want UTF-8 at some point.

Cheers

Richard
#13

[eluser]Dojjjan[/eluser]
this is making me insane!
im from sweden and need characters like åäö to be saved in my database which works just fine if i set $db['default']['char_set'] = "latin1";
$db['default']['dbcollat'] = "latin1_swedish_ci";
but when i should display it back in my viewer the data that comes from my database works fine but my html that also displays åäö comes back as åäö. And if i use UTF-8 åäö gets messed up in the database but the html lookes fine. I've used this: <?$this->output->set_header("Content-type: text/html; charset=latin1");?> in my viewer files and it still doesn't display right. Any ideas?
#14

[eluser]Mackstar[/eluser]
Did you try <?$this->output->set_header(“Content-type: text/html; charset=utf-8”);?>??
#15

[eluser]Dojjjan[/eluser]
yes, i've tried that and than all åäö's in my html displays right but åäö's that being fetched from the database comes out as � and other wierd signs, the same happens if i use utf8_swedish_ci. And as i said earlier: when i use <?$this->output->set_header("Content-type: text/html; charset=latin1");?> the opposite happens, my åäö's in the database displays as they should but those in my html (in the viewer) displays åäö.
Btw my database uses latin1_swedish_ci as collation, if i use utf-8 in my database my åäö's gets converted to questionmarks etc.

it wierd...
#16

[eluser]Dojjjan[/eluser]
hmm this seems to be browserspecific..
if i set
$db['default']['char_set'] = "utf-8";
$db['default']['dbcollat'] = "latin1_swedish_ci";
and use <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> in my header everything works fine in firefox, displays as it should and saves to the database correctly but in safari it changes out my åäös to questionmarks before it saves to the database..
#17

[eluser]Colin Williams[/eluser]
You are encoding the entities before you display them in the browser (using the htmlentities function), right? You should be.




Theme © iAndrew 2016 - Forum software by © MyBB