Dreamweaver reverts to western encoding after its been changed to UTF8

2

3

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.

Pickledegg

Posted 2009-09-25T09:28:55.657

Reputation: 603

Dreamweaver 'intelligently' changes everything for you. You better off using notepad than dreamwaver! – Mike – 2009-09-25T09:55:40.297

1Mike, 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 – 2009-09-25T14:50:13.833

That is the way it is a comment not an answer :) – Mike – 2009-09-25T23:38:43.157

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 – 2009-10-03T06:12:34.590

Answers

4

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.)

Arjan

Posted 2009-09-25T09:28:55.657

Reputation: 29 084

Give him more than 5 minutes! I have been waiting days for a response to mine! – William Hilsum – 2009-10-02T23:26:31.090

3

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"

William Hilsum

Posted 2009-09-25T09:28:55.657

Reputation: 111 572

1

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

enjoy!

Darius Vanan

Posted 2009-09-25T09:28:55.657

Reputation: 11

1

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.

Jodo

Posted 2009-09-25T09:28:55.657

Reputation: 129

0

i think if you want to remove whe BOM from utf-8 files on dreamweaver (creating files) you should do this:

it worked for me so try and see the result by yourself


on dreamweaver:

1º go to the settings;

2º on the category menu click on "new file" or "new document"

3º the first check box has to be selected, and the default encoding need to be utf-8


1º go to the " C:\Program Files (x86)\Adobe\Adobe Dreamweaver CS6 "

2º search for Default.php and Default.dwt.php

3º open notepad++ with admin rights

4º select the two files

5º rightclick and select edit with notepad++


in notepad++:

on eatch file do this:

1º click encoding on the top bar

2º on the submenu click click: "convert to utf-8 widout BOM"

3º save file

SkullWritter

Posted 2009-09-25T09:28:55.657

Reputation: 1

-1

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.

Mike

Posted 2009-09-25T09:28:55.657

Reputation: 225

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 – 2009-10-04T13:14:42.083