Welcome Guest, Not a member yet? Register   Sign In
Encoding issues
#1

[eluser]Swedie[/eluser]
I have converted my database into UTF-8, from ISO-8859-1. Gone through all data, looping through it and converting. Converting it to UTF-8. Also all tables and columns have been converted to UTF-8. All files have page encoding UTF-8 set under page properties (in dreamweaver) as well.

The problem is with å ä ö, swedish letters. They show correctly if entered manually in for example view files. But sometimes, and only sometimes, when pulled from dB the characters are like this: Vad g�r...
It should be: Vad gör...

I've also notices that if the å ä ö's are html entities, and I try to display the page without running html_entity_decode, they will show as: Vad gör du nu dÃ¥?
It should be: Vad gör du nu då?

There is something causing this and I just cannot find what...

Here is my HTML header for the page:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

There must be something in the view files that causes this?

Viewing the database from the mysql query browser or phpmyadmin and swedish letters and everything is displayed as expected.
#2

[eluser]Swedie[/eluser]
Note.

If I do a print_r of the data, the same problem occurs.

But if I put this before print_r, it displays correctly.

Code:
header('Content-Type: text/html; Charset=UTF-8');

How can that be?

I've also tried putting above in the view files loaded, but it doesn't change anything unless I change above code to charset ISO-8859-1, then it's scrambled again...
#3

[eluser]Swedie[/eluser]
I'm probably gonna be talking to myself here.

But just reloaded the two tables causing the problems and it appears that when I converted html entities back to "normal" and at the same time converted the table and data to utf-8 SOMETHING got messed up making the new "swedish characters" of some mixed-encoding that apparently behaves ... weird.
#4

[eluser]LuckyFella73[/eluser]
[quote author="Swedie" date="1291927069"]
But if I put this before print_r, it displays correctly.

Code:
header('Content-Type: text/html; Charset=UTF-8');
[/quote]
I assume you checked that (print_r) directly in your controller?

I'm sure you did set the encoding parameters in config.php and
database.php

The only idea I have now:
Did you save your view files utf-8 encoded? I often had problems
with the right encoding using different editors even if the default
encoding for the project was set to utf-8. Sometimes I had to click "save as" and
set the right encoding again ..
#5

[eluser]Swedie[/eluser]
[quote author="LuckyFella73" date="1291927963"][quote author="Swedie" date="1291927069"]
But if I put this before print_r, it displays correctly.

Code:
header('Content-Type: text/html; Charset=UTF-8');
[/quote]
I assume you checked that (print_r) directly in your controller?

I'm sure you did set the encoding parameters in config.php and
database.php

The only idea I have now:
Did you save your view files utf-8 encoded? I often had problems
with the right encoding using different editors even if the default
encoding for the project was set to utf-8. Sometimes I had to click "save as" and
set the right encoding again ..[/quote]

Yep, all files are utf-8.

Even though I posted above ugly "fix"... the issue still remains for print_r situations.

How do I check what encoding the page / browser is using? So I can compare.
#6

[eluser]LuckyFella73[/eluser]
With Firefox it should be "view/encoding" (topmenu). At least if
I translate my menu items to english directly ..
#7

[eluser]Swedie[/eluser]
Yep, it's UTF-8 in Firefox.

I am using Safari though. It's setting was "Standard"... and whatever that Standard is, it's wrong.

It's wrong in Safari, but displays correctly in Firefox.

And now tested in IE8, and it's as in Safari.

Only Firefox displayed it correctly... but why? lol haha...
#8

[eluser]LuckyFella73[/eluser]
Could you post a link to the page or is your page still in development?
It's really strange the FF displays it right and IE and Safari don't..
#9

[eluser]Swedie[/eluser]
Indeed very strange.

I've gone over to CI a month or two ago, but had to reuse some old code and done a quick and dirty job of making it speak with CI's core. It all works, also got the profiler going to tweak the performance a bit.

Anyhow, what I've done now is from previous just printing exports to the screen, I'm sending all my exports through a view file and also letting the view file know which browser that is currently being used.

So I have a scenario-driven header-script now that if it's Safari, then I actually have to set both UTF-8, and also running utf8_decode on what I'm printing to the screen.

Really really weird... it works, but it's ugly.




Theme © iAndrew 2016 - Forum software by © MyBB