Closed
Bug 1468461
Opened 6 years ago
Closed 6 years ago
When visiting Javascript, CSS, plain text files directly, the default encoding should be utf-8 when Content-Type doesn't declare a encoding
Categories
(Firefox :: General, enhancement, P3)
Firefox
General
Tracking
()
RESOLVED
DUPLICATE
of bug 1071816
Tracking | Status | |
---|---|---|
firefox62 | --- | affected |
People
(Reporter: zjz, Unassigned)
Details
Javascript have already supported Unicode, and right now, custom HTML markup is going through standardized, so there will be a growing trend of non-ASCII usages in both Javascript and CSS. When using Javascript/CSS files with non-ASCII characters, developers typically declare the encoding of the Javascript file through the HTML document(I.e. <script charset="utf-8"...>), and declare the encoding of the CSS file by @charset "utf-8"; Unforunately, most of them failed to also configure web servers to directly declare the encoding in Content-Type header responses for those Javascript/CSS files. So when you visit an page, things work prefectly, but if you directly visit Javascript or CSS files, or visit it by "View Page Source" and link to those files, chances are you will get messy code, because nowadays most files are encoded in utf-8, which Firefox doesn't default to when the Content-Type doesn't declare a encoding. I think it's about time to default them to utf-8, the predominant encoding, in both normal content tabs and "View Page Source" tabs, and Chrome has already done it.
Reporter | ||
Updated•6 years ago
|
Summary: When browsing the Javascript, CSS, plain text files, the default encoding should be utf-8 when Content-Type doesn't declare a encoding → When visiting Javascript, CSS, plain text files directly, the default encoding should be utf-8 when Content-Type doesn't declare a encoding
Reporter | ||
Updated•6 years ago
|
Priority: -- → P3
Reporter | ||
Comment 1•6 years ago
|
||
Improved solution: If a CSS file has @charset rule in its beginning(E.g. @charset "gbk";), that means the encoding is confirmed(I.e "gbk" in this example), so in this case, we don't use the default utf-8 encoding, but the encoding given by @charset.
Comment 2•6 years ago
|
||
Please set "intl.charset.fallback.utf8_for_file" to true via about:config as a workaround.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Comment 3•6 years ago
|
||
The discussion mentions web servers, so I presume documents obtained by HTTP. So, this is a duplicate to the wrong bug: bug 1071816 is about "file:" URL's only. The duplicate should have been to bug 815551.
Reporter | ||
Comment 4•6 years ago
|
||
(In reply to Vincent Lefevre from comment #3) > The discussion mentions web servers, so I presume documents obtained by > HTTP. So, this is a duplicate to the wrong bug: bug 1071816 is about "file:" > URL's only. The duplicate should have been to bug 815551. I don't think it's extactly duplicated, bug 815551 is talking about autodetecting encoding, here I'm talking about default encoding. In other words, default all files to utf-8 if Content-Type is not specifed. This is what Chrome does.
Reporter | ||
Updated•6 years ago
|
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Comment hidden (typo) |
Reporter | ||
Comment 6•6 years ago
|
||
If a website is programmed heavily in Unicode characters, in most cases, they will use utf-8, then the code in the website when the visitor tries to view in Firefox will turn completely messy code.
Reporter | ||
Updated•6 years ago
|
Status: REOPENED → RESOLVED
Closed: 6 years ago → 6 years ago
Resolution: --- → DUPLICATE
Reporter | ||
Comment 8•6 years ago
|
||
Sorry, just noticed the above comment. I think it's more reasonable to be a duplicate of bug 1071816. Because it's not talking about encoding detection based on text content.
Comment 9•6 years ago
|
||
Forcing to UTF-8 may break some sites, where an unspecified charset with HTTP means ISO-8859-1.
You need to log in
before you can comment on or make changes to this bug.
Description
•