Fun story about emoji and unicode:<p>I have a writing app I've developed for iOS, and a while ago received a bug report from someone saying the app crashed every time they tried to open their document. I couldn't figure out what was going on but after eventually receiving a copy of the document, I discovered that the crash was due to my incorrect handling of emoji characters.<p>Most string classes, including NSString in iOS, typically represent strings as sequences of 16-bit characters. With 65,536 possible combinations, this is perfectly adequate to support the characters from all major languages in use worldwide [1], plus emoji. Unicode does however allow for values outside of this range, which are represented by "surrogate" pairs of 16-bit values in the range D800-DFFF. It was these I was handling incorrectly, and had missed in my testing.<p>But if there's space in the 0-65,535 range to represent emoji, why would it be stored outside of this? Well, it turns out that the initial implementation of emoji in iOS used the "private use area" of this range to encode the character values [2]. NTT DoCoMo also had their own (incompatible) way of encoding emoji in the private use area [3]. When attempts were made to formally standardise on emoji in unicode, they couldn't use the private use area, and ended up going with values above 65,535.<p>If unicode had stuck to representing existing characters and symbols and said no to requests for stuff like emoji and klingon, string representation in modern software could have been kept a whole lot simpler.<p>Joel Spolsky has an excellent explanation of unicode and encoding issues here:<p><a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="nofollow">http://www.joelonsoftware.com/articles/Unicode.html</a><p>[1] To the best of my knowledge; correct me if I'm wrong<p>[2] <a href="http://openradar.appspot.com/6402446" rel="nofollow">http://openradar.appspot.com/6402446</a><p>[3] <a href="http://web.archive.org/web/20080216230900/http://www.nttdocomo.co.jp/english/service/imode/make/content/pictograph/basic/index.html" rel="nofollow">http://web.archive.org/web/20080216230900/http://www.nttdoco...</a>