Re: [css-syntax] ISSUE-329: @charset has no effect on stylesheet??

On Wed, Jan 15, 2014 at 4:48 PM, Tab Atkins Jr. <> wrote:
> On Wed, Jan 15, 2014 at 8:08 AM, Zack Weinberg <> wrote:
>> That's true but I don't think it affects Richard's point regarding the
>> exposition.  Concretely, I think that section 8.2 would be better if
>> it read something like this:
>> The @charset rule is a reflection in the object model of the
>> stylesheet's fallback encoding as determined by the algorithm in
>> section 3.2.
> But it's not!  A preceding BOM will override it, for example.  The
> @charset rule really, *truly* has no effect on the document, and
> should not be looked at for any reason.

That was what I was trying to indicate with this bit ...

>>  For compatibility's sake, an @charset rule will still
>> appear in the object model, as-if parsed as a normal @-rule, even if
>> it was not recognized as an encoding annotation by the algorithm in
>> section 3.2

... but I can see where it might not be emphatic enough.

> I've attempted to further clarify the explanatory text.

I think the text in the note is good, but the lead-in still gives the
wrong impression.  Let me try again.

| The @charset rule is an artifact of the algorithm used to [determine
| the fallback encoding] for the stylesheet.  That algorithm looks for
| a specific byte sequence as the very first few bytes in the file, which
| has the syntactic form of an @-rule. Those bytes are not discarded
| from the input, whether or not they influence the encoding actually
| used to process the stylesheet. Therefore, the stylesheet parser
| recognizes an @-rule with the general syntax
|    <at-charset-rule> = @charset <string> ;
| and, for backward compatibility, includes it in the object model for
| the stylesheet.  Modifying, adding, or removing an @charset rule via
| the object model has no effect (in particular it does *not* cause the
| stylesheet to be rescanned in a different encoding).
| The @charset rule is invalid if it is not the very first, top-level
| rule in the stylesheet, but it is parsed according to the normal
| syntax for @-rules, which are less restrictive than the algorithm that
| determines the fallback encoding.  Therefore, an @charset rule may
| appear in the object model even if it was ignored by that algorithm.
| (For instance, if it was written with extra whitespace or with single
| rather than double quotes.)


Received on Wednesday, 15 January 2014 22:12:19 UTC