HighDots Forums  

Re: @charset rule

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss Re: @charset rule in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: @charset rule - 10-06-2007 , 09:48 AM






François Patte wrote:
Quote:
Bonjour,

I am wondering why the @charset rule is not working for me.

I put at the early beginning of my index.css file:

@charset "utf-8";

no line before....

and in every html file:

link rel="STYLESHEET" href="index.css"

Everything is OK for all style definitions made in the index.css
(background, fonts style, size, and so on....

Only the charset definition is not working.... Browsers always return
ISO8859-1!!!
The @charset rule specifies only the encoding of the stylesheet. It
doesn't specify the encoding of the web page that links to the
stylesheet. It can't--the page's content can be completely processed and
the document model completely built in memory by the time the stylesheet
gets to the browser.


Reply With Quote
  #2  
Old   
François Patte
 
Posts: n/a

Default Re: @charset rule - 10-06-2007 , 10:18 AM






Harlan Messinger a écrit :
Quote:
François Patte wrote:
Bonjour,

I am wondering why the @charset rule is not working for me.

I put at the early beginning of my index.css file:

@charset "utf-8";

no line before....

and in every html file:

link rel="STYLESHEET" href="index.css"

Everything is OK for all style definitions made in the index.css
(background, fonts style, size, and so on....

Only the charset definition is not working.... Browsers always return
ISO8859-1!!!

The @charset rule specifies only the encoding of the stylesheet. It
doesn't specify the encoding of the web page that links to the
stylesheet. It can't--the page's content can be completely processed and
the document model completely built in memory by the time the stylesheet
gets to the browser.
Thanks to all. I did not understand that this declaration was limited to
the css file only...

And now I don't understand why it is necessary to declare the charset of
the css file.

--
François Patte
Université Paris 5 - Paris


Reply With Quote
  #3  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: @charset rule - 10-06-2007 , 10:43 AM



François Patte wrote:
Quote:
Harlan Messinger a écrit :
François Patte wrote:
Bonjour,

I am wondering why the @charset rule is not working for me.

I put at the early beginning of my index.css file:

@charset "utf-8";

no line before....

and in every html file:

link rel="STYLESHEET" href="index.css"

Everything is OK for all style definitions made in the index.css
(background, fonts style, size, and so on....

Only the charset definition is not working.... Browsers always return
ISO8859-1!!!
The @charset rule specifies only the encoding of the stylesheet. It
doesn't specify the encoding of the web page that links to the
stylesheet. It can't--the page's content can be completely processed and
the document model completely built in memory by the time the stylesheet
gets to the browser.

Thanks to all. I did not understand that this declaration was limited to
the css file only...

And now I don't understand why it is necessary to declare the charset of
the css file.
It *isn't* necessary unless (a) the server isn't sending a charset
parameter in a Content-Type header (because if the server is sending
one, then the @charset rule will be ignored anyway) and (b) the wrong
encoding would be applied following application of items 3 through 5
below, in order by priority from highest to lowest.

[Steps for determining the encoding of an external CSS sheet, from
http://www.w3.org/TR/CSS21/syndata.html#charset]

1. An HTTP "charset" parameter in a "Content-Type" field (or similar
parameters in other protocols)
2. BOM and/or @charset (see below)
3. <link charset=""> or other metadata from the linking mechanism
(if any)
4. charset of referring style sheet or document (if any)
5. Assume UTF-8


Reply With Quote
  #4  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: @charset rule - 10-06-2007 , 03:05 PM



Scripsit François Patte:

Quote:
I did not understand that this declaration was limited
to the css file only...
That's not surprising; virtually all people get very confused with charset
issues when they start working with them, but we can learn to keep the
confusion at a manageable level.

Quote:
And now I don't understand why it is necessary to declare the charset
of the css file.
Mostly it isn't. You normally use just ASCII characters there, and then the
charset mostly does not matter.

It matters if you use, say, a font name containing non-ASCII characters,
like

body { font-family: "François", sans-serif; }

(just assuming that you expect a font called "François" to exist somewhere).
People have used e.g. font names containing Japanese characters.

If this still puzzles you, c.i.w.a.stylesheets would be the right group to
ask about CSS issues.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #5  
Old   
François Patte
 
Posts: n/a

Default Re: @charset rule - 10-07-2007 , 04:11 PM



Jukka K. Korpela a écrit :
Quote:
Scripsit François Patte:

I did not understand that this declaration was limited
to the css file only...

That's not surprising; virtually all people get very confused with
charset issues when they start working with them, but we can learn to
keep the confusion at a manageable level.

And now I don't understand why it is necessary to declare the charset
of the css file.

Mostly it isn't. You normally use just ASCII characters there, and then
the charset mostly does not matter.

It matters if you use, say, a font name containing non-ASCII characters,
like

body { font-family: "François", sans-serif; }

(just assuming that you expect a font called "François" to exist
somewhere). People have used e.g. font names containing Japanese
characters.

If this still puzzles you, c.i.w.a.stylesheets would be the right group
to ask about CSS issues.
Thanks for this clarification and for the address.

--
François Patte
Université Paris 5 - Paris


Reply With Quote
  #6  
Old   
Andreas Prilop
 
Posts: n/a

Default Re: @charset rule - 10-08-2007 , 11:35 AM



On Sat, 6 Oct 2007, François Patte wrote:

Quote:
And now I don't understand why it is necessary to declare the charset of
the css file.
It is necessary when you want to include some special, non-ASCII
characters - perhaps in comments or a byte order mark.
http://www.unics.uni-hannover.de/nhtcapri/bom.css


Reply With Quote
  #7  
Old   
Ben C
 
Posts: n/a

Default Re: @charset rule - 10-08-2007 , 11:41 AM



On 2007-10-08, Andreas Prilop <aprilop2007 (AT) trashmail (DOT) net> wrote:
Quote:
On Sat, 6 Oct 2007, François Patte wrote:

And now I don't understand why it is necessary to declare the charset of
the css file.

It is necessary when you want to include some special, non-ASCII
characters - perhaps in comments or a byte order mark.
http://www.unics.uni-hannover.de/nhtcapri/bom.css
Also for values of the content or quotes properties. The latter would be
particularly likely to contain non-ASCII (although I don't think quotes
is much supported).


Reply With Quote
  #8  
Old   
André Gillibert
 
Posts: n/a

Default Re: @charset rule - 10-08-2007 , 02:36 PM



Andreas Prilop wrote:

Quote:
On Sat, 6 Oct 2007, François Patte wrote:

And now I don't understand why it is necessary to declare the charset of
the css file.

It is necessary when you want to include some special, non-ASCII
characters [...]
*Only* if you fail to provide another lower level specification of the
character map.
With HTTP, it's much better to use the Content-Type header.
The charset directive is a ugly hack that works well for ASCII-compatible
character maps when the character map of the CSS document isn't given to
the processing tool.

--
If you've a question that doesn't belong to Usenet, contact me at
<tabkanDELETETHISnaz (AT) yahoDELETETHATo (DOT) fr>


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.