Converting accented letters into special HTML characters

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
masterseo
Rank 0 - Newcomer
Posts: 1
Joined: Mon Jul 05, 2010 1:39 pm

Converting accented letters into special HTML characters

Post 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!
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Converting accented letters into special HTML characters

Post 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.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
MikeGale
Rank VI - Professional
Posts: 726
Joined: Mon Dec 13, 2004 1:50 pm
Location: Tannhauser Gate

Re: Converting accented letters into special HTML characters

Post 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.
User avatar
CaryD
Rank II - Novice
Posts: 46
Joined: Sun Oct 01, 2006 2:18 pm
Location: CA

Re: Converting accented letters into special HTML characters

Post by CaryD »

Dr. Kral
Rank 0 - Newcomer
Posts: 2
Joined: Sat Nov 06, 2010 12:38 pm

Re: Converting accented letters into special HTML characters

Post 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>
Post Reply