Latin-1 Entities
Latin-1 entities are accented/composite and other special characters encoded to tell browsers what character to print.
Example: ñ and © are special characters. The entities for those characters, respectively, are ñ and ©
While upgrading Master Quiz (now Master Quiz V2) to work with Spanish and other languages, I needed to create a method of translating special characters into entities for the browser. (See /a/24h/pl.pl?mq for Master Quiz V2.)
I'll share it with you.
It's been made into a script that allows you to paste a block of text into a textarea field, click a button, and receive that text with special characters changed into entities. It has a built-in entity table for reference.
Use it at the /a/24h/pl.pl?art241 demo page. Download the script at the demo page or directly at /a/24h/pl.pl?zip241
The character entities are those found in the table at http://www.htmlhelp.com/reference/html40/entities/latin1.html
That page also contains references for those who wish to use decimal or hex representations of special characters.
The Internet is a global system, reaching most cultures and languages on Earth, many of which use composite characters when writing. This little script can be a handy tool to translate composite characters into entities for browsers.
Conversion works by scanning text for special characters and replacing them with entities. If it finds an ñ, it's changed to the ñ entity, for example.
Programmers are welcome to copy and use the "%latin hash table" and the "Convert subroutine" found in the script in their own programs with attribution.
All are welcome to use the demonstration for converting blocks of text as the need arises. Bookmark the demo page.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©2004 Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.