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
d3.v3.js does not work if document encoding is not UTF8 #1195
Comments
This is correct. You either need: <!DOCTYPE html>
<meta charset="utf-8"> Or: <script charset="utf-8" src="d3.js"></script> Or you can use the minified version, which only contains ASCII: <script src="d3.min.js"></script> |
Actually, I take that back, you need UTF-8 encoding even with the minified version because of embedded format strings, such as "µ" for SI-prefix formatting. |
@mbostock Two small suggestions:
|
I would love to fix the header, but unfortunately I have no control over the headers served by GitHub Pages. The minified version already has munged symbol names using ASCII characters due to UglifyJS. But there is currently one non-ASCII character (µ, 0xb5) in a format string, which I can fix by adding a flag to UglifyJS. |
Thanks for the quick patch! |
… the charset to UTF-8. See d3/d3#1195 for the related d3 issue. Change: 135417926
On line 1285 of d3.v3.js we find some non-ASCII characters related to the definition of Pi.
var π = Math.PI, ε = 1e-6
While it may look cool to define variables named with Greek letters, it creates issue in HTML documents encoded in encodings other than UTF-8. If document encoding is not utf-8, and if D3JS scripts are included without explicit charset="utf-8" attribute, an "illegal character" error will pop up.
Possible resolutions may include:
The text was updated successfully, but these errors were encountered: