Page 1 of 1

Converting accented letters into special HTML characters

Posted: Mon Jul 05, 2010 1:44 pm
by masterseo
Hi!

Pls, any software is there to convert accented letters into special HTML symbols?

For example:

À - À
Ê - Ê

I have Dreamweaver 9 (CS3) but do not know how to convert.

Thank you!

Re: Converting accented letters into special HTML characters

Posted: Wed Jul 07, 2010 8:29 am
by Albert Wiersch
Hello,

I do not know about Dreamweaver, but HTML Tidy may do what you want. I just did a brief test and it did change À to À. You may have to "play" with the settings because it may also try to fix and reformat your page and you may not want that.

CSE HTML Validator has an interface to HTML Tidy. You may want to try that. You can try the trial on the website or the free BETA:
http://www.htmlvalidator.com/beta

Other programs integrate with HTML Tidy as well. I hope this helps.

Re: Converting accented letters into special HTML characters

Posted: Thu Jul 08, 2010 10:39 pm
by MikeGale
I don't know what programs and approaches you are used to.

Here's a couple of approaches that I have used in the past. (There may be online web services that do it too. I haven't checked.)

1) Write a little program that does a search and replace. Pretty trivial in the development environments I'm envisaging. The harder bit is getting a list of the entities and their conversions.

2) Use HTMLTidy as Albert suggests. If doing that it might be worth looking at the result and if it's really badly fouled up (and not fixable), try using a diff tool to update the "good" copy.

Depends how often you want to do it and what entities you encounter.

(I have a feeling HomeSite did that but Adobe have killed the product.)

Some text editors do this, but they'll often convert angle brackets to their encoded form. So you'll have to revert them afterwards.

Re: Converting accented letters into special HTML characters

Posted: Sun Jul 11, 2010 2:45 pm
by CaryD

Re: Converting accented letters into special HTML characters

Posted: Tue Feb 01, 2011 1:50 pm
by Dr. Kral
I just saw this and thought I would comment.

It is not necessary to convert those non-basic characters in HTML as you can use unicode (charset=UTF-8) provided that Dreamweaver allows you to. If not, try a European code set such as iso-8859-15 which allows such exotic characters.

On the other hand, if you must insert something into a page which you can not set to such character sets but uses iso-8859-1 then you can do a conversion using javascript.

Here the essence of the function:
asd=asd.replace(/([^\u0000-\u00A0])/g,function(a){return "&#"+a.charCodeAt(0)+";"}) ;

If you want named entities, then you can extract them from a list such as at <<http://www.ascii.cl/htmlcodes.htm>>

The nice thing about getting numeric entities is that the conversion is compact.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Convert to entities</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="CSE HTML Validator Professional (http://www.htmlvalidator.com/)">
<script type="text/javascript"><!--
function trans() {
document.getElementById("bb").value=
document.getElementById("aa").value.replace(/([^\u0000-\u00A0])/g,function(a){return "&#"+a.charCodeAt(0)+";"})
return }
--></script>
</head>
<body>
<p><button onclick='trans()'>Trans</button></p>
<p><textarea id="aa" rows="10" cols="50"></textarea></p>
<p><textarea id="bb" rows="10" cols="50"></textarea></p>
</body>
</html>