CodeIgniter Forums
Encoding problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Encoding problem (/showthread.php?tid=42183)

Pages: 1 2 3 4


Encoding problem - El Forum - 05-29-2011

[eluser]ponto[/eluser]
I have a problem with encoding, I know it's an ongoing issue and I have searched for it in the forum and haven't found a solution.

In the views I have meta="utf-8" and the character Ö looks like this �. If I change the meta to "ISO-8859-1" it's OK.
The problem is that data from the database shows up OK in "utf-8" but not in "ISO-8859-1".
I have tried to change encoding in database.php and config.php but if the page is OK the data is not.

Anyone have a clue on what to do?


Encoding problem - El Forum - 05-29-2011

[eluser]osci[/eluser]
Code:
<meta charset="utf-8"/>

or

Code:
<meta http-equiv='content-type' content='text/html; charset=utf-8' />

On a second thought: maybe your view is not saved as utf8?


Encoding problem - El Forum - 05-29-2011

[eluser]InsiteFX[/eluser]
As osci stated maybe you html page is saved in the encoding or its not being saved without the BOM!

I have seen this before and if its in the HTML page copy the compleate source and paste it into a text
editor like notepad this will get rid of any encoding characters then create a new HTML document in the
correct encoding and paste the source code back into it.

Some editors save the encoding along with the file when saved.

@osci, not sure if you know this but they recommend for html 5 to use both utf8 meta tags in a html 5 Document
this way if it will not support the new one it will fall back to the old one.

InsiteFX


Encoding problem - El Forum - 05-29-2011

[eluser]ponto[/eluser]
Thank's for your reply!

In Eclips it's possible to save the file in any endofline style and any encoding.
I've tried them all.
If I save the view-file with meta=ISO-8859-1 it works with the content but not with the data from the model.
The ÅÄÖ characters seams to be changed to the characters in config/foreign_chars.php.
(töstsöåä)

In order to save data in mysql I have changed the encoding in config/database.php to ISO-8859-1. Otherwise the data with those characters wont save to database. I have also tried different encoding in the database and tables itself.


Encoding problem - El Forum - 05-29-2011

[eluser]osci[/eluser]
@InsiteFX you are correct about the fallback


Encoding problem - El Forum - 05-29-2011

[eluser]InsiteFX[/eluser]
Also if you are using phpMyAdmin it will always default to a collation latin1_swedish_ci no matter what you change your collation to!

Click on the operations tab on top and see what the collation is set for on the bottom, if wrong change it.

InsiteFX


Encoding problem - El Forum - 05-29-2011

[eluser]snifty[/eluser]
ponto, you need to make sure that *everything* is set to Unicode.

* the db encoding should be set UTF-8
* the db collation should be utf8_general_ci
* each table's encoding should be set UTF-8
* each table's collation should be utf8_general_ci
* you should make sure all your .php files are saved as utf-8
* the charset should be marked in the <head> of your pages
* you should make sure Apache (or whatever you're using) is sending utf-8

Any of the above can cause borkery, speaking from painful experience.


Encoding problem - El Forum - 05-29-2011

[eluser]InsiteFX[/eluser]
If you are using an .htaccess file you can add this to it:

<ifModule mod_php5.c>
php_value default_charset utf-8
</ifModule>

InsiteFX


Encoding problem - El Forum - 05-30-2011

[eluser]eshaa83[/eluser]
great discussion is going on dear...Thanks for sharing


Encoding problem - El Forum - 05-30-2011

[eluser]ponto[/eluser]
Thank's to all and especially InsiteFX and snifty for your reply.

The Application is on a wamp locally on windows, just to test I uploaded the whole app to a server on Amazon and it seams to work there.

I must give up the wamp server for now.

Thank's