开发者

Maybe encoding is the bad guy?

It is a very simple dynamic page (php) with menu items w开发者_如何学运维hich changes a GET id property which determins which text body to render.

As in hittinging the "Front Page" menu will render the site again with an internal id set to 1 where a few if-else determins what text to display.

Now, i was clicking around the links just to see that the text changed accordinglig but every 3-6 times i would hit a random menu item, some of the chars ( ø æ å) in the text on the entire page was replaced by (æ = æ ø = ø å = Ã¥)

The text is static on the site, it is not gotten from a database yet. This problem occers now and then and i cannot find a pattern in its occerens.

Anyone got a shoot at what might be wrong?

My sites meta tag is set to uft-8 (<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> so the encoding should be able to parse it)

The only thing i have been messing with on the site is .htaccess but as it stands now its empty.


Ensure your character encoding is set to UTF-8 both in the http-equiv="Content-type" meta tag and in the Content-type header sent by the server - usually browsers prefer the real header over the meta one.

To send the header from your PHP script, use header('Content-type: text/html; charset=utf-8');

Another way would be doing it in your htaccess file.


You may need to set the HTML encoding:

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

Also, your pages should be encoded in UTF-8. Almost any editor offer choice of encoding.


Check the encoding of your files and the encoding declared in the HTTP headers and / or <head>. They must match in order to have the good character shown in the browser.

If you're under linux, you can change the encoding of a file with iconv.

If you still have problems, theres mainly two way to resolve them :

  1. Using html entities, but it can be very tedious.
  2. Declare your page as UTF-8, and use utf8-encode

To declare your page as encoded with UTF-8, add the following to your <head> :

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


Try adding this to your html in your head:

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


It seems it was a browser problem after all. . . When i was using firefox it keept screwing up but when i switched to IE it was all good. . . There does not seem to be any problem for other people so guessing i got some crap on my puter i need to weed out.

But thanks alot for your awnsers!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜