Converting accented letters into special HTML characters

Discussion about HTML and XHTML related issues.

Converting accented letters into special HTML characters

Postby masterseo » Mon Jul 05, 2010 1:44 pm

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!
masterseo
Rank 0 - Newcomer
Rank 0 - Newcomer
 
Posts: 1
Joined: Mon Jul 05, 2010 1:39 pm

Re: Converting accented letters into special HTML characters

Postby Albert Wiersch » Wed Jul 07, 2010 8:29 am

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.
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2649
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: Converting accented letters into special HTML characters

Postby MikeGale » Thu Jul 08, 2010 10:39 pm

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
MikeGale
Rank VI - Professional
Rank VI - Professional
 
Posts: 637
Joined: Mon Dec 13, 2004 2:50 pm
Location: Tannhauser Gate

Re: Converting accented letters into special HTML characters

Postby CaryD » Sun Jul 11, 2010 2:45 pm

User avatar
CaryD
Rank II - Novice
Rank II - Novice
 
Posts: 46
Joined: Sun Oct 01, 2006 2:18 pm
Location: CA

Re: Converting accented letters into special HTML characters

Postby Dr. Kral » Tue Feb 01, 2011 2:50 pm

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>
Dr. Kral
Rank 0 - Newcomer
Rank 0 - Newcomer
 
Posts: 2
Joined: Sat Nov 06, 2010 12:38 pm


Return to HTML and XHTML

Who is online

Users browsing this forum: No registered users and 4 guests