RE: Question of the Week -- CSS and character Encoding

Hi Russ,

Some suggestions below, unfortunately in CAPITALS because my mail client
didn't put < before all of your lines...

============
Richard Ishida
W3C

contact info: http://www.w3.org/People/Ishida/ 

http://www.w3.org/International/ 
http://www.w3.org/International/geo/ 

See the W3C Internationalization FAQ page
http://www.w3.org/International/questions.html



> -----Original Message-----
> From: public-i18n-geo-request@w3.org 
> [mailto:public-i18n-geo-request@w3.org] On Behalf Of Russ Rolfe
> Sent: 23 September 2003 23:18
> To: public-i18n-geo@w3.org
> Subject: Question of the Week -- CSS and character Encoding
> 
> 
> 
> Here is my submission for this week.
> 
> Regards, Russ
> 
> -=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> =-=-=-=-=-=-=-=-=-=-=
> 
> Question?
> 
> How do I declare the character encoding of a CSS (Cascading 
> Style Sheets) style sheet?
> 
> Answer:
> 
> Just as you should always declare the character encoding for 
> an HTML document 
<http://www.w3.org/TR/1998/REC-html40-19980424/charset.html#h-5.2.2> you
should also declare the character encoding for a separate external style
sheet file.  This way it is not left to chance on how the style sheet's
encoding will be interpreted. 

I THINK THIS PARA BELONGS LOWER DOWN - IF NOT IN THE BY THE WAY SECTION.
I'D PREFER TO START WITH THE ANSWER TO THE QUESTION THAT COMES NEXT.
(BUT SEE BELOW)

To set the character encoding you may use the "@charset at-rule".  Its
syntax is:

I'D PREFER: ... USE THE "AT-RULE" @CHARSET.

      @charset <IANA defined charset name>

I THINK THIS SHOULD BE:
	@CHARSET "<IANA DEFINED CHARSET NAME>";

The CSS2 specification states:

"At most one @charset rule may appear in an external style sheet -- it
must not appear in an embedded style sheet -- and it must appear at the
very start of the document, not preceded by any characters. After
"@charset", authors specify the name of a character encoding. The name
must be a charset name as described in the IANA registry (See [IANA].
Also, see [CHARSETS] for a complete list of charsets)."

I AGREE WITH TEX THAT IT WOULD BE GOOD TO PARAPHRASE THIS - ESPECIALLY
SO THAT IT IS CLEAR WHAT 'EMBEDDED' MEANS.

HOW ABOUT (SWITCHING TO LOWER CASE, >>> MEANS NEW PARA):
>>>@charset rules are not needed and must not be used for style
declarations embedded in a document. They are for use in linked style
sheets.
>>>Only one @charset rule may appear in an external style sheet and it
must appear at the very start of the document, not preceded by any
characters. The name must be a charset name as described in the [IANA
registry] (See [CHARSETS] for a complete list of charsets).

The important thing to note here is that this command must appear at the
very beginning of the file -- even before any comments.

PREVIOUS PARA WOULD NOT BE NEEDED IF WE DID AWAY WITH THE QUOTE

Thus an example of labeling your CSS file as UTF-8 encoded would be:

      @charset "UTF-8"   SHOULD ADD A SEMI-COLON AT THE END - NOT
ESSENTIAL, BUT RECOMMENDED PRACTISE


I FEEL WE ARE MISSING TWO THINGS:
[1] AS TEX SAID, SOME COMMENTS ABOUT WHY YOU NEED TO DECLARE THE
ENCODING (ESPECIALLY AS MOST PEOPLE DON'T).  THIS SHOULD GO IN THE
BACKGROUND I THINK.  IT SHOULD MENTION THE NEED TO CORRECTLY RECOGNISE
NON-ASCII MARKUP (TAG AND ATTRIBUTE NAMES, AND IN SOME CASES ATTRIBUTE
VALUES), AND NON-ASCII VALUES FOR THE CONTENT PROPERTY.

[2] SOME EXPLANATION OF THE CASCADE USED TO DETERMINE THE ENCODING AS
DESCRIBED IN http://www.w3.org/TR/CSS21/syndata.html#x60 .  MAYBE THIS
IS WHAT YOU WERE ATTEMPTING WITH YOUR FIRST PARA IN THE ANSWER??  HOW
ABOUT SOMETHING LIKE:
>>>Even though the CSS specification says that it is possible to specify
the encoding of a CSS file by the server sending the information in the
HTTP header, you should also explicitly declare the character encoding
for a separate external style sheet file (in the same way as you should
for an HTML file). This way it is not left to chance as to how the style
sheet's encoding will be interpreted. 

OR
>>>It is possible to declare the encoding of an external, linked CSS
file by setting the server to pass the encoding information in the HTTP
header. However, whether you do that or not, you should also explicitly
declare the character encoding for a separate external style sheet file
(in the same way as you should for an HTML file). This way it is not
left to chance as to how the style sheet's encoding will be interpreted.
References:



    CSS 2.1 @charset spec    http://www.w3.org/TR/CSS21/syndata.html#x60
    CSS 2.0 @charset spec    http://www.w3.org/TR/CSS2/syndata.html#q23
    IANA Charset Names
http://www.iana.org/assignments/character-sets 
    HTML 4.0 Specify the Character Encoding                     
 
http://www.w3.org/TR/1998/REC-html40-19980424/charset.html#h-5.2.2


HOPE THAT HELPS,
ri

Received on Wednesday, 24 September 2003 08:07:45 UTC