What is different and when and where it is better to use one or the other:

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
  • one
    The victory of utf-8 is inevitable !!! - deivan_
  • This is clear, but for now, the default browsers are configured on windows-1251 ((( - skegg
  • depending on what OS you are sitting;) - Zowie
  • ubuntu wrote a page for myself, coded in utf-8. Instead of Russian letters, all browsers gave out cracks until I forced them to determine Unicode. Like this. - skegg
  • if I didn’t use pens in the settings, then in linux and ubuntu in particular, the browser defaults to the locale encoding (for example, I have utf8) problems are observed only on those pages where either the locale is not specified or is incorrect (For example, in the utf8 header and the page itself win1251) - cavinc

1 answer 1

The difference is that there are two bytes on UTF-8, and one byte on windows-1251. Therefore, the text in Unicode takes up more space. In general, other things being equal, it is better to always use UTF-8; this greatly facilitates development for different languages.

  • four
    All ascii characters in utf-8 occupy 1 byte the rest from 2 to 6 (actually up to 4) UTF allows you to use any characters (at least Chinese), and cp-1251 only ascii, Cyrillic and another 62 (?) . - avp
  • A little offtopic, but something was remembered, as I prefigel in due time from the fact that utf-8 and unicode - 2 different encodings) - Sh4dow
  • Then we still have to remember UTF-16, which is much more often confused with Unicode - avp
  • one
    Then don't forget that UTF-16 happens to be BE and LE, and UTF-8 happens with BOM and without BOM: P - toxicdream
  • one
    @ Sh4dow: UTF-8 and Unicode are different entities, approximately like “passenger train” and “railway transport”. As already noted, Microsoft uses the name “Unicode” for UTF-16 in its programs, but Microsoft is not authorized to define what Unicode is. - Incnis Mrsi