Jump to content

Correct Charset


[dx]

Recommended Posts

Hi, I'm getting problem with charset. My page won't show chars like č ć š ž đI've used this tag:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>

But I still can't get work it properly.In my SMF forum there's same meta tag, and chars are shown very well, but problem is in my page.RegardsHaris

Link to comment
Share on other sites

You have to encode the characters to UTF-8 (it would look like this: č ć Å¡ ž Ä‘), then declare the character set as UTF-8. not ISO-8859-1.Or you can use HTML entities: &#269; &#263; š ž &#273;

Link to comment
Share on other sites

So it mean I need
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

and what else?

And you need to encode the characters to UTF-8.PHP has a utf8_encode() function.
Link to comment
Share on other sites

I don't know all the character sets, you could search on Google if you want to find the one that uses the characters you want on your page.It should be one of these:http://en.wikipedia.org/wiki/Category:ISO_8859Actually, ISO-8859-2 looks like the one you're looking for.If your page uses PHP, sending a header is more likely to make the page render correctly than a meta tag:

<?php header("Content-type: text/html;charset=ISO-8859-2"); ?>

Link to comment
Share on other sites

What happened?Also, remember to actually save the file with the right encoding.

Link to comment
Share on other sites

Nothing happend, same as before.I've added

<?php header("Content-type: text/html;charset=ISO-8859-2"); ?>

in head.php file and still nothing.

Link to comment
Share on other sites

Scrap everything you have (include files too; assuming you have any) and follow these steps:1. Cteate a new PHP file in Notepad with the following as its contents:

<?php header('Content-Type: text/html;charset=utf-8'); ?>

2. While still in Notepad, go to "File", "Save As...". In the second drop down, where it says "Encoding", select "UTF-8". As you can guess, also change the file type from ".txt" to "All files" and save the file with a ".php" extension.3. Close Notepad, and open the same document again.4. Type whatever HTML you want below what you just made. When done, save the document... what you typed NOW should appear in your browser in the same way as you typed it.NOTE: If you're obtaining the information from a database, that's one more place where you need to make sure your data is already in UTF-8, and that PHP uses UTF-8 as the transmission encoding. The way to set both depends on the type of database and the API you use in PHP (e.g. MySQL, MySQLi, MS SQL, PDO MySQL, PDO MS SQL, etc.).

Link to comment
Share on other sites

Well yes, I have installed SMF forum, and one web page which uses same db to show informations. On forum chars are correct and shown as well, but on web not.SMF forum uses this tag

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Link to comment
Share on other sites

Well yes, I have installed SMF forum, and one web page which uses same db to show informations. On forum chars are correct and shown as well, but on web not.SMF forum uses this tag
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

The trick is not in the HTML, but in PHP. This SMF forum sets its DB tables as UTF-8, and sets their client encoding as UTF-8. If you want to obtain information from SMF's database, you need to do the same. Like I said, how you do it depends on many factors. For example, if you use MySQLi, you must use mysqli::set_charset().
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...