A Conversation for Website Developer's Forum

Putting unusual symbols into html

Post 1

Frankie Roberto

Okay I need a crash course in getting certain symbols to display in html pages.

The particular ones I'm after are the symbol for 'For All' which looks like an upside down capital A and the existential quanitifier, which looks like a back-to-front E. Both are listed in the unicode set at http://www.unicode.org/charts/PDF/U2200.pdf but I have no idea if, and how, I can get them to display in an html page.


Putting unusual symbols into html

Post 2

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

Start by setting the charset for the document to utf-8 with a meta tag then use the entity to display the symbol. The entity would look like &#x____; where the underscores are replaced by the hexadecimal code for the symbol you want. There's also a little useful utility that works like the "insert symbol" command in Word but lists all the Unicode characters are present. I can't remember the name of the utility but I have it back at my office.

You have to be careful about fonts too. Not all fonts have all Unicode characters, so if you are specify the font on your page check it out first. http://www.alanwood.net/unicode/fonts.html is a good resource for fonts and all things Unicode in general.
smiley - dog


Putting unusual symbols into html

Post 3

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

And invest in a good grammar checker, and never never get up to let the dog out when you are in the middle of typing a sentence.
smiley - dog


Putting unusual symbols into html

Post 4

Frankie Roberto

Hmm, all I'm getting is [] squares.


Putting unusual symbols into html

Post 5

Frankie Roberto

Ah, got stuck with differences between hex and decimal...


Putting unusual symbols into html

Post 6

Ion the Naysayer

As an added bonus, Unicode works this way in any SGML derived language which includes any form of XML as well. There are also named shortcuts for most of the symbols, such as ©   & and so forth. I think I remember seeing a table of common ones on the W3C website but I'm not quite sure.


Putting unusual symbols into html

Post 7

Frankie Roberto

but you have to define entities for XML don't you? I seem to remember h2g2 having a problem with that, hence entities requiring an tag.


Putting unusual symbols into html

Post 8

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

h2g2's character set is ISO-8859, not UTF-8, and that is what limits it. You actually do not have to use the entities at all. If you have an editor that supports Unicode and the proper keyboard layout or input method, you can type the character directly, and the character itself is entered (as opposed to the entitity which is a representation of the single unicode character using 8 ascii characters). If you don't use entities, you don't have to define them. Dreamweaver MX works with Unicode directly, as do all of the MS Office products (Office 2000 and up). Check out the alanwood.net for other software. I can recommend some Mac stuff if you are using a Mac.
smiley - dog


Putting unusual symbols into html

Post 9

Frankie Roberto

Ah yes, but if you want people to submit things in xml, and they don't have the ability to encode the character directly (no button on keyboard), it's impossible to let people type in entities like &foreach; without defining them.


Putting unusual symbols into html

Post 10

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

That's where one of the utilities come in, many of them free:
http://www.alanwood.net/unicode/utilities_fonts.html

Character Agent was the one I was thinking of, some of the newer ones look like they may be better. Keyman has been around for a long time, but last time I looked they hadn't added Unicode support and their web site said something about Unicode being an untested and likely passing fad. I guess they changed their minds.

Rather than pasting in the entity, most of them paste in the character itself. Of course if it's easier to define the entities (which probably has been done already and just needs to be copied or referenced), then go for it.
smiley - dog


Putting unusual symbols into html

Post 11

Ion the Naysayer

I believe the definitive answer is here:
http://www.w3.org/TR/REC-xml#charsets

The way I'm reading that, you don't need to declare the hex values of the entities. I'm not sure if the text versions are part of the XML specification or if they only work in XHTML.


Putting unusual symbols into html

Post 12

Frankie Roberto

Look what I can do: ¥ € § ...


Key: Complain about this post