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

On Wed, Jan 22, 2014 at 2:11 PM, Richard Ishida <ishida@w3.org> wrote:
>
> PS: I'm curious, however, about why the parsing of the initial bytes is so
> draconian in requiring specific quotes and exactly one space. HTML5 doesn't
> require that, afaict.

It would not be technically difficult for Gecko to bring the special
parser defined at
http://dev.w3.org/csswg/css-syntax/#determine-the-fallback-encoding
*closer* to alignment the parser used for @-rules, subject to some
sort of "within the first N bytes" constraint as for HTML.
Concretely, we could make it accept this Perl-style regular expression
without much trouble:

    /\A \s* @charset \s* ( " [^"]+ " | ' [^']+ ' ) \s* ; /ix

where \A means "the very beginning of the style sheet" and \s means [
\r\n\t\f] (consistent with the definitions of "whitespace" and
"newline" elsewhere in the specification).

However, this is still not a perfect match to the main parser -- in
particular comments would still be forbidden before the semicolon --
and I am not aware of any particular *need* to make this change, i.e.
I am not aware of the as-specified parser causing any trouble for
authors.  I could be persuaded otherwise with data (e.g. a scan of the
public Web for @charset constructs which demonstrated that more than a
few of them were written with single quotes, uppercase, or extra
whitespace, and therefore inoperative).

zw

Received on Wednesday, 22 January 2014 19:28:36 UTC