Re: Encoding/characterset/font family confusion



Erwin Moller wrote:

A few day ago I discovered that the euro-sign is not defined in all
fontfamilies.

Browsers are *supposed* to switch fonts when they encounter a character
that does not exist in the current font. Unfortunately, Internet Explorer
is famously bad at this.

They cannot produce the right sign no matter if I use € or the
hexadecimal equivalent.

Yep -- it's not a problem with the way you've specified the character,
just a problem that the browser is trying to display it using a font that
doesn't contain that character.

After a little research I found I could put font-tags around the euro-sign
with another font-family (Arial in this case) to get the Euro sign.

If you care about the symbol being rendered correctly in legacy browsers,
then this is the best solution. Either change the fonts of your whole
page, or use a little PHP+HTML+CSS:

$str = str_replace('€',
'<acronym class="e" title="euro">&euro;</acronym>',
$str);

With CSS:

acronym.e { border-bottom:none; font-family: "Arial"; }

If you use output buffering, then you should be able to do this with
minimal code changes.

I'm actually doing something fairly similar on a current project, but with
ampersands instead of euro-signs. I wanted them all rendered in a
particular font which has an especially nice ampersand, but didn't want
the rest of the page to appear in that font.

Also, take a look at Jukka's page on the euro sign:
http://www.cs.tut.fi/~jkorpela/html/euro.html

As far as character sets are concerned, do not worry too much. HTML
documents effectively have two character sets: the one they're transmitted
in and the one they're translated into by the browser. The one they're
translated into is always Unicode, so always includes the euro symbol. So
you just need to worry about the one they're transmitted in -- you've
chosen ISO-8859-1, which does not include the euro symbol, but all that
means is that you need to use an entity instead -- you can't just type in
a raw €.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
.



Relevant Pages

  • Re: Font Substitution on XP
    ... If your selected font doesn't have the glyph for the character ... browsers improve, and as users move from a browser-like operating ...
    (comp.fonts)
  • Re: XHTML 1.0 Strict and the Apostrophe
    ... substituting the generic square box ... character for it. ... It comes down to the font. ... in browsers on PCs will have a glyph for U+2019. ...
    (comp.infosystems.www.authoring.html)
  • Re: Help, keybd_event emulate a ? character.
    ... sending the right character or characters and ... having the glyph in the font. ... Not every font will have that one. ... > Yes, it's a Euro symbol. ...
    (microsoft.public.windowsce.app.development)
  • Re: en space in IE
    ... That's probably the main practical problem with using an en space character. ... This also depends on the font, since even old browsers might be able to display the en space if it exists in the current font - the font just picks up a glyph from the font and uses it, without really knowing or caring about the fact that the glyph consist of empty space only. ... Use whatever CSS technique (sadly requiring extra markup) you find least awkward. ...
    (comp.infosystems.www.authoring.html)
  • Re: Problems with Firefox and font-family property
    ... I was able to use the Unicode character code "\u21D2" to ... will not show up on IE6 under any font I ... but I've set out some of my observations, amongst other browsers, at ... I'm definite that "Lucida Sans Unicode" contains this ...
    (comp.infosystems.www.authoring.stylesheets)

Quantcast