Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[questions/qa-css-charset] "Default" encoding for CSS? #547

Open
JamesTheAwesomeDude opened this issue Oct 2, 2023 · 2 comments
Open

[questions/qa-css-charset] "Default" encoding for CSS? #547

JamesTheAwesomeDude opened this issue Oct 2, 2023 · 2 comments

Comments

@JamesTheAwesomeDude
Copy link

JamesTheAwesomeDude commented Oct 2, 2023

[source] (https://www.w3.org/International/questions/qa-css-charset) [en]

Is there any official guidance on how browsers should interpret CSS documents that lack any encoding declaration?

For example, the latest version [117.0.2045.47] of Microsoft Edge yields mojibake when rendering this page: https://www.devever.net/~hl/omi

  • The (X)HTML page declares its encoding to be UTF-8 in a <meta> tag
  • The external CSS file's encoding is not declared in any way
  • The external CSS file contains several non-ASCII byte sequences:
    • { 0xe2, 0x80, 0x93 } (can be interpreted as “–” or as “–”)
    • { 0xc2, 0xb7 } (can be interpreted as “·” or as “·”)
    • { 0xe2, 0x8f, 0xa9, 0xef, 0xb8, 0x8e } (can be interpreted as “â�©ï¸Ž” or as “⏩︎”)
      [*The latter includes U+FE0E Variation Selector 15, which is supposed to make it display in its non-Emoji form.]
    • { 0xe2, 0x8e, 0x8c } (can be interpreted as “⎌” or as “⎌”)
    • { 0xe2, 0x9d, 0x8f } (can be interpreted as “â��” or as “❏”)
    • { 0xe2, 0x96, 0xbd } (can be interpreted as “â–½” or as “▽”)

Obviously, the administrator of this website SHOULD be declaring his encoding (whether it be UTF-8 or Windows-1252). But, given that he hasn't, is Edge's behavior here at least ALLOWABLE?

@JamesTheAwesomeDude
Copy link
Author

JamesTheAwesomeDude commented Oct 2, 2023

yields mojibake ...

Actually, on further testing, Edge's behavior here is intermittent, and it switched to UTF-8 permanently after I loaded the CSS file's URL in its own document tab (presumably something to do with cached auto-detection?)

But my question still stands as originally posed.

@xfq
Copy link
Member

xfq commented Oct 12, 2023

When a style sheet is embedded in the style element or style attribute, the style sheet shares the character encoding of the document.

When a style sheet resides in a separate file, see https://www.w3.org/TR/css-syntax-3/#input-byte-stream for how browsers should interpret.

There are some tests in:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants