[Javascript] Encoding Unicode characters in HTML

Charles Albrecht charles.albrecht at gmail.com
Mon Aug 22 00:12:54 CDT 2005


On 8/18/05, Judah Frangipane <judah-fc at t8design.com> wrote:
> I know how a person can encode an ampersand in html. They use "&amp;"
> and this code is rendered by the browser into "&".
> 
> What I don't know is how to encode a unicode character. I am trying to
> encode a bullet character. The keystroke is ALT+0149 as displayed here
> •. There are many more unicode characters that I would like to let my
> users use. How do I encode the characters so that the browser renders
> them correctly?

The bullet character is unicode code point 8226 (2022 in hex), not
0149. 149 is its "ASCII" value in some character encoding. Maybe ISO
8859-1, maybe UTF-8, but maybe not. If you use &#149; (anything over
127) you may need to make sure you specify a character encoding for
your page to be certain it displays correctly for browsers on all
platforms.

Use &bull; for a bullet. But &#x2022; and &#8226; are both usable.

See http://en.wikipedia.org/wiki/Unicode_and_HTML for more about
Unicode encodings for your html.

-Charles
 charles.albrecht at gmail.com


More information about the Javascript mailing list