E
E
Evgeny Bakulin2016-03-23 02:25:08
Character encoding
Evgeny Bakulin, 2016-03-23 02:25:08

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

4 answer(s)
S
Sergey delphinpro, 2016-03-23
@stranger2015

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.

S
SergeyKhvoschevskiy, 2017-11-17
@SergeyKhvoschevskiy

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

A
Andrey, 2020-03-24
@AndryG

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

I
Igor_Ya, 2020-11-09
@Igor_Ya

Bom is a specification for NET languages.
In Powershell, I have cracks for the Russian language, after resaving the bezbom file in any of the formats, be it bom-bezbom or something else.
There were, as before, problems with web js the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question