English 中文(简体)
Arabic characters corrupt on landing, fine after refresh - UTF8
原标题:

I have an php page with mixed Latin and Arabic characters. The charset declaration tag is in the html code

and the file is saved as UTF-8. All the text is static and in the php file (does not come from a DB or an external source)

When I browse to the site some pages randomly get corrupt in IE and FF and display all question marks. After I refresh the page, text is displayed properly though... I have been working with Arabic and Hebrew for a long time and this is the first time I run in to this issue. Can anybody think of a cause?

Chrome is always fine...

最佳回答

Turns out the script reference that was before the meta description was causing the problem. I moved <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> to be the first item after the opening head tag and this is no longer an issue. Thanks for all the comments..

P.S I wasn t the one who code this page, and only working on localizing it, thats why I didn t even think that meta tag being after script would even make a difference...

问题回答

Try to send appropriate header, something like this:

header("Content-Type: text/xml; charset=utf-8");

Try using UTF8_encode on your content:

http://php.net/manual/en/function.utf8-encode.php

If you have some text you want to store in a DB and display even if the page encoding is latin-1, there is a free tool that can convert Unicode to escaped HTML:

http://www.sprawk.com/tools/escapeUnicode





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签