byte order mark, BOM problem with utf-8 files

Hello folks,
Is there any issue to save files (which contains cyrillic symbols for example) with BOM ?
When i used PHP Designer 7.1 there was an option when saving file "Save with BOM" and i have no problems.
But in PHPStorm 1.0.1 when i save file (layout file in ZF project) there is problems with page view in browsers. And when i reopen that file with PHP Designer it shows that file was saved without BOM.

Hope there is some solvation of that problem which i just don't know ;)

Thanks for attention, regards Chinga

p.s. sorry for my bad english)


isn't noone encountered that problem?


Hello Chingis,
What encoding do you use for your files?
I presume you are using UTF-8?
IDEA does not insert BOM into UTF-8 files. It does, however, preserve the BOM if it was there before.
According to the Unicode spec,
"Use of  BOM is neither required nor recommended for UTF-8"
( Chapter 2.6)

Browsers should not have any problems showing UTF-8 pages without BOM provided that you specified

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> tag or set the encoding in the HTTP header.

Alexey Kudravtsev
Intellij IDEA  developer
JetBrains, Inc
"Develop with  pleasure!"

Thanks for your reply, Alexey.
Yes, now i see that BOM isn't required in other browsers(Opera 10, Chrome 4, IE 8) except of Firefox 3.6
In FF 3.6 it continues to appear. So it could be only problem of FF(omg, how can it be:))

But for "IDEA ... it does, however, preserve the BOM if it was there before." i can say that PHP Storm doesn't. Cause i reSave my file in another IDE to insert BOM after editing in PHP Storm.

However i will google for messages about problems with BOM in FF and write soon here again.


Could you please attach the file with BOM and your IDEA encoding settings (the file encodings.xml under your .idea directory).
We will investigate why the BOM was not preserved.


I'm sorry for late answer.
I attached layout file saved in PHP storm after editing(without bom) and after saving it in PHPDesigner(i clicked in save dialog flag "WIth BOM", it was unchecked so i guessed that PHP Storm saved file without BOM).
It's layout file in ZF project.

Also i noticed that problem with cyrrillic symbols occurs only in firefox when i use "ZF debug" controller plugin. It places <style> block just after openning <head> tag. So meta information with charset info situates after that block. Maybe it cozes problem, as when i turn of ZF debug plugin firefox shows page normally.


BTW, It will be useful to file a bug into ZF tracker - everybody will benefit if they just fix it.


If you talking about "ZF debug" plugin, its third parity project, so i don't think it's problem of ZF. But i will surely write to author of "ZF debug"


Yup, the problem was in "ZF debug" plugin. I make it to place <style> and <script> blocks after all meta tags. And now i have no problems with encoding.

For people who have same problem: just need to fix regex in library\ZFDebug\Controller\Plugin\Debug.php file

protected function _output($html)
        $response = $this->getResponse();
        $response->setBody(preg_replace('/(</head.*>)/i', '$1' . $this->_headerOutput(), $response->getBody()));

need to change </head.*>  to <\/head>, and in protected function _headerOutput()  add closing </head> tag after closing </script> tag.

I attached updated file.


Please sign in to leave a comment.