Swedish characters on static page

#1
[eluser]Unknown[/eluser]
Hello!

I have a fresh install of CI 1.7.1 and directly after install I tried to change the welcome message to a message in swedish. But I'm unable to get swedish characters to render correctly.

I've tried to
- Change default_charset in php.ini between UTF-8 and ISO-8889-1
- Change $config['charset'] between UTF-8 and ISO-8889-1
- Set header in the welcome controller with $this->output->set_header("Content-type: text/html; charset=ISO-8889-1");

Nothing seem to work. If I just create a PHP page with the code below it renders correctly.
<?
print "Hej. Det här meddelandet är på Svenska.";
?>

Here's what I get from CI:
Hej! Det h�r meddelandet �r p� Svenska.(default)
Hej! Det hŠr meddelandet Šr pŒ Svenska.($this->output->set_header("Content-type: text/html; charset=ISO-8889-1")Wink

Correct result:
Hej. Det här meddelandet är på Svenska.

I'm on a mac, using CODA as my editor, and I'm using MAMP as my web server.

I can't understand why UTF-8 doesn't work.

Any ideas?

Best regard,
--Andreas

#2
[eluser]Johan André[/eluser]
Hey!

The welcome-view of the default install is missing some stuff.
Use this as a template for your views:

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;
        &lt;title&gt;Page title&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;!-- Content goes here! --&gt;
    &lt;/body&gt;
&lt;/html&gt;

Be sure to save the files using the UTF-8-encoding too...

PS! Jag är svensk också! Smile

#3
[eluser]Unknown[/eluser]
Hi Johan,

Thanks for the fast reply! I've noticed that new views I create work as expected. And when I deleted my old welcome_message.php and replaced it with a fresh page from your template it works! So maybe my old page wasn't saved with UTF-8 encoding? Don't know, but I'm glad it works. :-)

Best regards,
--Andreas

ps. Roligt att det finns flera Svenskar här! ds. :cheese:

#4
[eluser]Johan André[/eluser]
I actually don't know either, but when doing these steps that kind of error disappears... Smile
I think that saving the files as UTF-8 is sufficent, but using the correct doctype and encoding for the document helps crippled browsers (like the browsing-the-internet-disabled Internet Explorer-family).

Glad it works though...

PS! Vi kanske borde starta ett svenskt community! Det fanns lite snack för ett tag sedan om att ses med ett gäng svenskar... DS!

EDIT: I see you are using Coda, and therefore using OSX so your problem should not be the browser... Smile

#5
[eluser]nermion[/eluser]
Hi guys

I have a follow up question. I also need swedish characters. I'm not sure what my problem is so here is description of what I have so far.

I'm building application with mysql database.

I've got a table where I store data and among columns I have one for company_name, I've set this one to latin1_swedish_ci kollationering, so swedish chracters that are entered on webpage and sent to database end up like this:

"Exempel F?retag"

I need this "Exempel Företag"

Do you know what do I need to set these columns in mysql to ensure that I get correct data in database and correct characterts displayed to user when viewing data from database on the webpage.

Can you give me some suggestions.

#6
[eluser]Johan André[/eluser]
Encoding: utf8
Collation: utf8_swedish_ci

Does the trick for me... Smile

#7
[eluser]nermion[/eluser]
thanks

I've actually managed to get it working with latin1_swedish_ci and converting all my php files to utf8 and also putting that encoding in html. I wonder whats the difference then between latin1_swedish_ci and utf8_swedish_ci

#8
[eluser]Johan André[/eluser]
Great!
I'm not sure about the differences between the collations.
I always use UTF-8 as encoding-type on my pages and utf8_swedish_ci on the db.
I think the collation has something to do with sorting. I had some problem in the past sorting swedish characters correctly (the å, ä and ö was sorted like a, a and o). Changing the collation took care of it... Smile

PS! Känns lite konstigt att skriva på engelska när man vet att du kan svenska... Men jag antar att andra kan lära sig något om jag håller mig till engelska! Smile DS!

#9
[eluser]nermion[/eluser]
Yeah its mostly so that others could understand what we did in case they need help Smile

Tack för hjälpen!

CodeIgniter känns verkligen som rätt vall, rätt så roligt att jobba med den! Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.