Search
  • Convert Foreign Characters to the Correct HTML codes in Dreamweaver

    Date: Sep 27, 2010  |  Categories: Html  |  Written By: Mike Ballan  

Now last year I was using VIM to code all my HTML & CSS in and I loved it, but since then I have lost my version of VIMSKI which had been customised to do a lot of cool things one of which was the ability to auto convert foreign characters to the correct HTML codes, which you can image if your translation a website from English to French if you didn’t have this it could take a long time to do using just the “Find and Replace” function of DW.

But fear not a little hunt on Google has shown me the answer and it’s so simple to do. All you need to do is make two files, first, convertCF.htm [not .html]:

<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine 5.0//dialog">
<html>
<head>
	<title>convertCF</title>
	<script src="convertCF.js"></script>
</head>
<body onload="convertCF();">
</body>
</html>

And second, convertCF.js:

function canAcceptCommand(){return true;}
function convertCF() {
var theDOM = dw.getDocumentDOM();
var theDocEl = theDOM.documentElement;
var theWholeDoc = theDocEl.outerHTML;
theDocEl.outerHTML = escapeExtended(theWholeDoc);
window.close();
}
function escapeExtended(s){
	return s.replace(/([\x80-\uffff])/g, function (a, b) {
		 return "&#"+b.charCodeAt()+";"
	});
}

Then all you need to do is move these two files into you commands folder which should be located somewhere like this:

C:\ > Program Files > Adobe > Adobe Dreamweaver CS3 > configuration > Commands

After you have put them there just restart your DW and then click on the “Commands” tab and you will see a new option called “convertCF” at the bottom which when clicked will replace all special chars in whole document with their correct HTML codes.

Thanks go to “freedom_razor” over at Codingforums.com for shorting this out..!



One Response to “Convert Foreign Characters to the Correct HTML codes in Dreamweaver”

  1. Lisa Says:

    Haha, shouldn’t you be cahgnrig for that kind of knowledge?!

Leave a Reply

Back to Top