Re: Where are unicode escapes allowed?

* Christof Hoeke wrote:
>http://www.w3.org/TR/css3-syntax/#referring defines how characters not 
>allowed in the current encoding may be put in a stylesheet anyway. It is 
>also said to use this escape facility only if needed. But theroretically 
>(maybe for obfuscation purposes) it may be used to extremes:

At the moment you are better off with the CSS 2.1 syntax and grammar
documents; escapes are allowed as part of identifiers, strings, the
url(...) notation and the #... notation and perhaps other features
outside CSS 2.1.

>/* .x2{color:#0a0} fully escaped: */ 
>\00002e\000078\000032\00007b\000063\00006f\00006c\00006f\000072\00003a\000023\000030\000061\000030\00007d

This would be parsed as single identifier, escaping special chars
like the curly braces removes their special meaning, so the rule
has no declaration block.

>I guess using unicode escape sequences for special CSS characters like 
>., #, {, : }, etc generally escape theses characters as well (I could 
>not find the spec page but remember reading this somewhere).

This is implicit by the way you parse the escapes which is largely
determined by where they are allowed.

>The result would be: Unicode escape normalization (meaning using the 
>actual chars) can only happen *after* the tokenization is done and not 
>on the raw css text?

That is correct. Think about escaping " and ' inside a string literal,
if you remove them before parsing, the style sheet would be malformed.

>Could one define a list of Tokens (defined at 
>http://www.w3.org/TR/css3-syntax/#tokenization) for which escapes are 
>possible? Would the following list be correct and complete:

You can simply take the generic syntax as defined in CSS 2.1 and
track where 'escape' is allowed. That would give you all the rules.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Thursday, 8 November 2007 14:53:01 UTC