Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting HTML character entities to characters

Strings

Converting HTML character entities to characters

by  BillyRayPreachersSon  Posted    (Edited  )
To convert HTML character entities to characters without having to use a lookup table, get the browser to do the work for you:

Code:
<html>
<head>
</head>
    <script type="text/javascript">
        var theStr = '&#305;&#287;&#252;&#351;&#246;&#231;&#304;&#286;&#220;&#350;&#214;&#199;';
        function convertHtmlEntitiesToCharacters() {
            var newDiv = document.createElement(newDiv);
            newDiv.innerHTML = theStr;
            alert('Entities:\n' + theStr + '\n\nCharacters:\n' + newDiv.innerHTML);
        }
    </script>
<body onload="convertHtmlEntitiesToCharacters();">
</body>
</html>

Dan

[link http://www.coedit.co.uk/][color #00486F]Coedit Limited[/color][/link][color #000000] - Delivering standards compliant, accessible web solutions[/color]

[tt]Dan's Page [blue]@[/blue] Code Couch
http://www.codecouch.com/dan/[/tt]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top