惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Spread Privacy
Spread Privacy
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recorded Future
Recorded Future
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
Recent Announcements
Recent Announcements
V
V2EX
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
C
Check Point Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
量子位
Attack and Defense Labs
Attack and Defense Labs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
CERT Recently Published Vulnerability Notes
腾讯CDC
Latest news
Latest news
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
美团技术团队
The Cloudflare Blog
T
Tenable Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
SecWiki News
SecWiki News
Webroot Blog
Webroot Blog
N
News | PayPal Newsroom
博客园 - 叶小钗
博客园 - Franky

David Baron's Weblog

Software engineering, responsibility, and ownership Software engineering, responsibility, and ownership David Baron's weblog: Security and Inequality Running animations on the compositor thread David Baron's weblog: Tying ecosystems through browsers David Baron's weblog: Payments on the Web Thoughts on migrating to a secure Web David Baron's weblog: The need for government David Baron's weblog: Priority of constituencies How browser developers should seek feedback from Web developers A possible approach to shorter release cycles David Baron's weblog: Fifteen years Why debug builds (and assertions) are important Ten years of the Mozilla Foundation Open licensing at the W3C Why adding compositing and blending to CSS is harder than it looks How you can help with removing -moz- prefixes Moving bug history out of the primary display of a bug report Beware of locale-specific behavior in the C library Eating dogfood and shipping software Specification style and the future of the Web The bug system I wish I had CSS border-image changes and unprefixing Improving font size readability on Firefox for Android David Baron's weblog: CSS Animations, part 2 Hue-preserving color inversion with SVG filters Changes to handling of @-moz-keyframes David Baron's weblog: window.matchMedia() David Baron's weblog: CSS Animations What does a blur radius mean? Crash analysis in the future David Baron's weblog: calc() David Baron's weblog: colorDepth David Baron's weblog: Hidden complexity in specifications The most important field in a bug report: the summary WOFF font format submitted to W3C David Baron's weblog: :-moz-any() selector grouping setTimeout with a shorter delay Faster repainting in SVG foreignObject David Baron's weblog: Distributed Extensibility David Baron's weblog: Broadening crash analysis Correlating crashes with binary extensions or plugins David Baron's weblog: ex-HTML Downloadable font formats for the Web Web Accessibility as a Political Movement David Baron's weblog: CSS priorities David Baron's weblog: Bug priorities David Baron's weblog: Semi-vacation Some new CSS features in Firefox 3 David Baron's weblog: New selectors David Baron's weblog: The age of bugs Seeking a good Linux distribution David Baron's weblog: Teaching to the test David Baron's weblog: March 2008 David Baron's weblog: February 2008 David Baron's weblog: January 2008 David Baron's weblog: October 2007 David Baron's weblog: September 2007 David Baron's weblog: August 2007 David Baron's weblog: June 2007 David Baron's weblog: April 2007 David Baron's weblog: March 2007 David Baron's weblog: January 2007 David Baron's weblog: September 2006 David Baron's weblog: August 2006 David Baron's weblog: July 2006 David Baron's weblog: May 2006 David Baron's weblog: January 2006 David Baron's weblog: December 2005 David Baron's weblog: October 2005 David Baron's weblog: September 2005 David Baron's weblog: June 2005 David Baron's weblog: May 2005 David Baron's weblog: April 2005 David Baron's weblog: March 2005 David Baron's weblog: February 2005 David Baron's weblog: October 2004 David Baron's weblog: September 2004 David Baron's weblog: August 2004 David Baron's weblog: June 2004 David Baron's weblog: May 2004 David Baron's weblog: April 2004 David Baron's weblog: March 2004 David Baron's weblog: February 2004 David Baron's weblog: January 2004 David Baron's weblog: November 2003 David Baron's weblog: October 2003 David Baron's weblog: September 2003 David Baron's weblog: August 2003 David Baron's weblog: July 2003 David Baron's weblog: June 2003 David Baron's weblog: May 2003 David Baron's weblog: April 2003 David Baron's weblog: March 2003 David Baron's weblog: February 2003 David Baron's weblog: January 2003 David Baron's weblog: December 2002 David Baron's weblog: November 2002 David Baron's weblog: September 2002
David Baron's weblog: February 2006
David Baron · 2006-02-13 · via David Baron's Weblog

Character encodings (addendum) (10:05 -0800)

Mike Hommey wrote me with a good point about my earlier entry: that the statement that If everybody used UTF-8, all these problems could go away isn't really true, because of one problem: the unification of CJK characters means that the same codepoint in Unicode is sometimes used to represent the same conceptual character, but one that's drawn in a significantly different way in Simplified Chinese, Traditional Chinese, or Japanese.

So we really need textual data to specify its human language in addition to its character encoding. Some of the old-style character encodings can be used to imply a certain language, but UTF-8 cannot. So switching to UTF-8 would increase the need for language identification (although the problems language identification fixes would only appear for an even smaller subset of languages than the current problems related to character encoding identification).

But that doesn't detract from the point that you're always better off explicitly specifying your character encoding.

And in fact, I wanted to mention one other thing along those lines: yet another reason for specifying encoding is form input. If your Web page has forms in it, and you don't specify an encoding on the page or in the form, then you won't know the encoding of the data you get back from the form. And you'll have the same problem all over again, but in your database. (And for forms, it's particularly good to use an encoding like UTF-8, since any characters that the user types will work.)

Why Web authors must specify character encodings (00:43 -0800)

[ I've been looking for a clear explanation of why it's important to label Web pages with character encodings. I want it because I want something to point to when emailing Web authors who don't when their pages cause problems for me (and my default of UTF-8, which I chose primarily so that I write UTF-8 in Mozilla's Bugzilla, which is still broken). I couldn't find one, so here it is. I've chosen to be a little bit loose with terminology in order to get the point across more clearly. ]

In the earlier days of computers, different parts of the world had different ways to convert the ones and zeros stored in a computer file into characters that mean something to a human. Different ways allowed different sets of characters to be represented. (In the even earlier days of computers, they often differed between different manufacturers, but the market took care of that problem because users had trouble moving data from one system to another.)

Then the Web came about. The World Wide Web. And suddenly people were reading things written in another part of the world. But even if they knew the language, the characters didn't always come out right, because the computers were sending ones and zeros from end to end, and the computers at the two ends sometimes thought same sequence of ones and zeros represented a different character. The same sequence could be interpreted as "jalapeños", "jalapeños", "jalape単os", "橡污灥쎱潳", or "慪慬数뇃獯".

A way of converting sequences of ones and zeros to characters, or the other way around, is called a character encoding. The files sent on the Web are still just sequences of ones and zeros, but the Web browser needs to know what characters those ones and zeros represent. So it needs to know which encoding to use.

Bad Web content often doesn't tell the browser which encoding to use, so Web browsers often guess based on the user's language. So an American's Web browser would guess the normal encoding used for English, but a Japanese user's browser would guess the normal encoding used for Japanese. This means that even if a page works fine for you and all your colleagues, it might not work for somebody in Japan. Or for me, because I have my browser configured strangely. (The reason Web browsers do this is that the first Web browsers just displayed the ones and zeros the way they were interpreted on the computer where the browser was running. So authors got used to pages that they wrote working for themselves, and for other people in their country. So keeping these old pages working and making the Web truly World Wide became conflicting goals.) Some Web browsers even try to guess which encoding the page uses by looking at the pattern of ones and zeros.

Many encodings have the same rules for dealing with the characters that were in ASCII, a very old character encoding that includes only the unaccented letters, numbers, and a small number of symbols. This means problems with encodings often don't show up until you use characters outside of ASCII, such as the copyright sign ©, the accented characters in Résumé or jalapeño, or the Euro sign €. That's why the example above had three variants that were mostly the same. So just because some of your pages work both for you and people elsewhere in the world doesn't mean they all will.

Your operating system or your editor has an encoding that it uses by default when you type characters into a file. If you know what encoding that is, you can label your pages using it. Once you've done this, there's a much higher chance that if the characters in the page work for you, they'll work just as well for everybody else, at least as long as they have a font that can display the character. If you don't know what it is, you should guess, label your pages anyway, and test to see whether it worked. If it worked, then it's probably OK, but remember to test again if you use unusual characters for the first time. Finding out for sure is better than guessing, though.

One final note, about two technical terms that often come up in discussions of this topic: Unicode is the standard that contains the "complete" list of characters. UTF-8 is a new(er) encoding that can encode all the characters in Unicode. If everybody used UTF-8, all these problems could go away.