Currently I am developing a web site by php in Persian ( Farsi language ).The problem is when I submit a form in firefox all fonts get destroyed. like below pictures:
I have checked the code ( include meta tags and others thousands of times ) and it makes it more wierd that this happend only on firefox and no other browser after submission.Is there any bug related to firefox or am I supposed to change any attribute of form .
I am quiet desperated . please help me if anyone has a clue.
One detail of your screenshot caught my attention:
This looks a bit like a LTR variant of UTF-8 BOM.
To quote from Wikipedia Byte Order Mark:
A text editor or web browser interpreting the text as ISO-8859-1 or CP1252 will display the characters "" for this.
I would therefore assume you inject invalid text-fragments having such a BOM inside and existing HTML document (AJAX?), your Firefox browser detects that the document can't be valid Unicode any longer and therefore falls back to ISO-8859-1 which once was the default character encoding for all text documents on the internet.
As the CSS rules still apply, the LTR display was preserved, just the text-encoding meta-information was changed.
Please take care: Having the correct headers is one thing to signal the correct encoding, however it does not unburdened you from actually provide correctly encoded text-data.
I must admit, those BOMs can be pretty tricky, so they are easy to overlook.
Solution: Do not inject any BOM here. If you provide back HTML from a PHP file, check the PHP file that it doesn't use any BOMs.
I figured this issue out.
I used <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />.
I replaced it with UTF8 header in PHP :
header('Content-Type: text/html; charset=utf-8');
and problem solved.
I had another problem that solved with this change.My website pages loaded twice in firefox and its solved now.It seams that fire fox dont like that meta tag at all ;)
Related
I'm using Laravel, this is probably the first time in 2 years that i've come across this problem. I'm having questionmarks in my text ( result of encoding issue's )
ori�ntatie,
The weird thing is i'm using the correct meta tag in my head
<meta charset="UTF-8">
I've tried different fonts, I'm also using typekit, i disabled it but the problem persists. The text is copy pasted from a photoshop design, so no text out of the database.
Any idea where I should start to look for a solution in my code. I'm not seeing it. Thanks
Solution
PHPStorm was causing the issue.
My whole project's File Encoding settings were set to the wrong encoding.
To fix it you can go to
File - File Encoding - UTF-8
When I try that line:
echo "<script >alert(' مشترك بالفعل!'); location.href='index.php';</script>";
in chrome it display garbage but firefox display it correctly. What's wrong with chrome?
Any help will be appreciated. Thanks!
That is because, firefox rockssss – The COMPLETE PHP Newbie 47 secs ago
That comment is probably right (although maybe accidentally. :) Firefox may be sniffing the document's encoding with more flexibility than Chrome is.
The most likely explanation is that your HTML document's encoding is not defined, and the PHP source file (where you store the text in) is stored in a different encoding than you are outputting.
Make sure the encoding of the PHP file, and the HTML document you're outputting, match.
The encoding of the PHP source file can probably be set in your IDE
The encoding of the HTML page is defined by the Content-type header your web server sends, and/or the Content-type META tag.
This question gives a complete overview: UTF-8 all the way through
I have an issue with character encoding:
I have this page: http://www.studiomille.jp/class/
(its in japanese but the character in question is from chinese i think)
FF shows it correctly, IE (all versions) and Chrome doesn't (sorry larger screenshots):
FF Screenshot:
IE Screenshot:
(there are other character that are different throughout the site, this is just one example)
Everything is set to UTF-8:
* PHP sends header: Content-Type:text/html; charset=UTF-8
* PHP starts with: mb_language('uni'); mb_internal_encoding('UTF-8');
* meta tag: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
* all files are saved with UTF-8 encoding with DreamWeaver CS3
* the same font is used in all the browsers.
On that page nothing comes from the db, everything is hard coded.
The site has the same behavior on my localhost too.
So why only FF gets it right and how can I make it work on IE also?
These two characters are variants of each other but share the same code point.
See http://en.wiktionary.org/wiki/将.
The variant showing up in Firefox is the Japanese Kanji variant, the "incorrect" one is the Chinese Hanzi variant. If all you have is the code point/UTF-8 encoded character, it's ambiguous which variant should be rendered. As a great example, try copying the two different characters from the aforelinked Wiktionary entry and paste them into a different application. You'll likely end up pasting a different variant than you copied for one of them.
To solve this, you can hint the language to the browser. Taken from the Wiktionary entry:
<span lang="zh-Hans" xml:lang="zh-Hans">将</span>
<font lang="ja" xml:lang="ja">将</font>
(Not that you should be using the <font> tag anymore...)
This is still no guarantee how the character will be rendered, but if the browser takes the hint, it should work. You should be able to set the lang for the whole document, instead of each character individually.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
it is not working like i have my site which can be translated in 20 languages but in some languages like turkish , japanese it shows � symbol instead of space or " and many others
Since I don't know your site I can just guess in the dark.
Setting
<meta charset="utf-8" />
will not be the only thing you have to do. If your document is saved as ASCII your problems won't be solved. Additionally you have to set the document encoding correctly (the meta tag just tells the browser which encoding to use, not which one IS actually used). So open the document with a (good) text editor like SublimeText / Notepad++ or what you prefer and set the encoding to UTF-8.
for php, you need to add a utf-8 header
header ('Content-type: text/html; charset=utf-8');
Letting know browser that text is in unicode and actually providing data in unicode is not the same. Check your files for unicode, database data for unicode and transformation that is done with it while serving. Provide more information to pinpoint your problem
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Just adding a Content-Type header in HTML doesn't make anything utf-8. It merely tells the browser to expect utf-8. If your source files are not in utf-8, or the database columns in which data is stored isn't utf-8, or if the connection to the database itself isn't utf-8, or if you're sending a HTTP header telling it isn't utf-8, it will not work. There's just one way of dealing with utf-8: make sure everything is in utf-8.
The problem is caused by the admin tool you are using. The tool injects data into a UTF-8 encoded data in some other encoding. As the tool has not been described, the specific causes cannot be isolated. The pages mentioned do not exhibit the problem, and they specify the UTF-8 encoding in HTTP headers, so the meta tag is ignored in the online context (though useful for offline use).
I am using notepad++ for php coding.
I don't have any problem with format set up using Encode in ANSI.
However when I use Encode in UTF-8, either I have a strange character at the top or not showing anything.
Q1. Am I supposed to use ANSI?
Q2. Why do I am not able to display anything when I use UTF-8
My sourse code for the header is following.
<html>
<head>
<title>Hello, PHPlot!</title>
</head>
Is that because I am not using UTF-8 in the header?
It's probably a Byte Order Mark. You can use the 'Encode in UTF-8 without BOM' mode in notepad++.
This question has some helpful information about using UTF-8 with PHP. You will also (as you suggested) need to set the content type in either the header or a meta tag in order for the browser to interpret it correctly.
It sounds like you are using UTF-8 with a BOM (which has issues) and your server is failing to specify the encoding correctly.
IIRC, BOM is unavoidable in Notepad, so I would suggest using a better editor. I'm fond of Komodo Edit myself.
(Also note, that a Doctype is required in HTML documents)
As Tom Haigh says, it's probably the BOM. It's not necessary for UTF-8 encoding, so you can safely leave them out.
However I should point out that PHP has very weak support for UTF-8 - be prepared for a bumpy ride. Take a look at this page for some details on problems you might encounter.