Answer the question
In order to leave comments, you need to log in
UTF-8 vs UTF-8 without BOM - which when to use?
Please help me understand:
UTF-8 and UTF-8 without BOM - what is the difference in usage? What is the best way to save files?
Once upon a time I got the impression that UTF-8 is more universal, it is better to use this encoding - then I dealt with HTML, CSS +/- JavaScript, but later - dealing with PHP - I got experience saying that UTF-8 without BOM is preferable (there were problems, just because of UTF-8)
So, how to be? What to use?
My experience so far is this: for the client side - UTF-8 (or there is no difference), for the server side - UTF-8 without BOM - is that right? Why?
Answer the question
In order to leave comments, you need to log in
There are no differences, except for the presence / absence of a marker. The encoding is the same - utf-8. According to the unicode standard, the marker should be.
Removing the BOM marker when saving is only necessary for PHP, which for some reason cannot correctly process normal unicode files.
The day fought until I found out that this is such a fundamental moment for browsers. So, when saving a local copy of the html page with Cyrillic wget'om or curl'om, we apparently have a copy of UTF without BOM. Browsers display such a page with Cyrillic in krakozyabry. In Notepad++ I recode to "UTF BOM" format and the problem is solved
I will add. that there is a difference for "not php" files. For example, .js files, as a rule, browsers give without specifying the charset in the headers. If the BOM tag is in the file, then it is read as UTF, otherwise each browser reads as it wants. My fox opened JS without BOM as latin1, and chrome - cp1251
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question