Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Dreamweaver CS3, and when I built an application I forgot to ensure that the encoding was set to UTF8.

I went through all my files and changed the encoding from western european to UTF8. This was fine until I noticed that SOME files revert back to western european encoding when re-opened.

No matter how many times I change the encoding back ( using ctrl+j and choosing the dropdown in page properties ) and save the files, it STILL reverts back to western when opened.

This only seems to happen on certain files, and some are fine. I've tried creating a new file in UTF8 and copying the contents of the old one into it. The problem persists so I'm thinking that the file may contain odd characters that are causing Dreamweaver to 'intelligently' change the encoding.

Any ideas are welcomed. Many thanks.

share|improve this question
    
Dreamweaver 'intelligently' changes everything for you. You better off using notepad than dreamwaver! –  Mike Sep 25 '09 at 9:55
1  
Mike, it doesn't if used as an editor. There are reasons why I'm using this software at the moment and your suggestion, although it may well be true, does not help in this case :) –  Pickledegg Sep 25 '09 at 14:50
    
That is the way it is a comment not an answer :) –  Mike Sep 25 '09 at 23:38
    
my guess is that it might be related to another program opening and making changes, and losing the UTF-8 encoding in the process.. but I haven't used DW in a really really long time :) –  warren Oct 3 '09 at 6:12

5 Answers 5

up vote 3 down vote accepted
+150

Files encoded as UTF-8 do not necessarily need any special marker (the so-called byte-order mark, or "BOM") to indicate they are encoded as such.

It depends on your settings whether or not Dreamweaver adds such marker. Especially for non-HTML files, it's often recommended not to add such marker for UTF-8 at all. Like a BOM in a CSS file is said to sometimes cause the initial rules in the file to fail in some browsers. And prior to version 6, PHP simply considers the BOM as output, which might yield "Cannot modify header information - headers already sent" errors.

Computer programs have a few options to determine the encoding when opening a file that has no marker: scan the first hundred bytes of the document to see what's in there, or (like for XML and HTML files) trust the value of some encoding specified as human readable text in the document. And if all fails: simply use some default when the encoding is not otherwise known.

So, there's a few things to check:

  1. Is a BOM used for the files that Dreamweaver correctly detects as UTF-8, and in the files that it detects as Western? On a Mac, open Terminal and run:

    file my-file.html

    ...which might yield something like:

    my-file.html: UTF-8 Unicode (with BOM) text, with CRLF line terminators

    On Windows, you could find the same command in Cygwin. Or use a hex-editor to see the first bytes (EF BB BF for a UTF-8 BOM). Or set a browser to explicitly use Western and do a View Source (or use an old editor that does not understand UTF-8) to see if it shows the first bytes as funny characters, such as . That's your UTF-8 BOM then.

    (If you find ÿþ or þÿ then it's UTF-16. Bad, unless you're writing something like Chinese! Not seeing any funny characters at all in this answer? Then read about using "Arial Unicode MS" at Get Dingbats to appear in Firefox 3?)

  2. Do the internals of the file specify an encoding? Such as:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 

    (In HTML files, the Content-Type should be specified before the <title> tag.)

  3. If both are present: do they match?

  4. If Dreamweaver thinks a file is not UTF-8: does it matter? So: are there any special characters in that file? A plain ASCII file does not change when it is saved as UTF-8 (unless a BOM is prefixed).

(Note that I assume you're still working with local files. If things are actually fetched from a web server, then there's also the Content-Type HTTP header. See Firefox displays garbage characters in lieu of web page then. Once you upload your files to a web server, you need to ensure the web server sends the same encoding in its Content-Type headers.)

share|improve this answer
    
Give him more than 5 minutes! I have been waiting days for a response to mine! –  William Hilsum Oct 2 '09 at 23:26
    
awesome, thanks. –  Pickledegg Sep 20 '10 at 8:03

I have only had to deal with a different encoding once and I had similar results to what you are saying.

I believe that it is due to the fact that Dreamweaver simply forgets / fails to detect settings on some files.

I changed this option and it worked fine for me:

alt text

Edit > Preferences > New Document... Click the checkbox "Default encoding:" / "Use when opening existing files that don't specify an encoding"

share|improve this answer

Menu Modify > Page Properties > Encoding and specify the encoding to convert the document to

enjoy!

share|improve this answer

None of these answers are correct.

If you want any file to open as UTF-8 when you open it, just add this line as the second or first line of your document:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 

I add this line as the second line of all of my CodeIgniter file shards... since there is no header tag in most of the files.

This tricks Dreamweaver into working properly: setting a default Encoding charset. The preferences pane does not work at all.

share|improve this answer

Check out the iconv maybe...

EDIT: I don't know if you tried that iconv yet. Maybe you were too lazy to install cygwin. I found web interface to iconv in that wiki link. Check it out.

share|improve this answer
    
If present, then one also needs to change the encoding as specified in the file contents itself, like <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> –  Arjan Oct 4 '09 at 13:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.