views:

80

answers:

1

I have created a file and saved it as UTF-8 I placed this code:

<div class="top_pic">
    <img src="<?php echo $this->images_dir ?>image.jpg" alt="doc ao fim do dia" width="632" height="320"/>
</div>
<div id="conteudo_menu">
    <?php echo $this->conteudo_menu ?>
</div>
<div id="item_list">
    <?php echo $this->vinhos_lista ?>
</div>

I save and reopen and it's iso-8859-1.

I have tried modifying it using notepad++ and dreamweaver.

Always the same result. This is messing up the page, because the page presents strings in utf-8.

Please!! Someone help me!!

EDIT:

I finally fixed this. I used mb_convert_encoding to force everything to be utf8.

Thanks for all the help!

+1  A: 

PHP doesn't look at or even know what encoding your script file is - PHP simply considers it as a bunch of single-byte characters, and something happens based on these characters. Nothing prevents you from using the characters in such a way that the bytes correspond to UTF-8 (which you should, by the way), but it's your responsibility to send the appropriate Content-Type header (header('Content-Type: text/html;charset=utf-8'); before any output is sent) and/or META-tag to make sure the page is interpreted correctly, and to ensure any database connections use the proper character set.

Michael Madsen
I edited the question. But as I said the file is saved as utf8. In the main template I have utf8 in the header!
AntonioCS
Well, that suggests you messed something up in your placement. Have you checked if PHP provides any new warnings or notices? It could be that your addition suddenly causes output before the appropriate header()-command. (Keep in mind, if there is a charset defined in the header - and your server might be adding a default one - the spec says that the META-tag should be ignored, so if the correct utf-8 header is suddenly not sent, that could be it.)
Michael Madsen
The doesn't seem anything related to php. It's like windows is encoding to ANSI when I save it with this code. At least this is the conclusion I am getting at
AntonioCS
Okay, now you lost me. What exactly *are* you asking about? The encoding detected by some editor? If there are no "high" characters in the file, then it may very well be detected as ISO-8859-1, since BOMless UTF-8 (PHP wants it without a BOM, so...) with no characters >=128 will differ in their binary representation from the ISO-8859-1 representation.
Michael Madsen