“Unable to convert hex escape sequence (no high character) to UTF8-encoded character.” UserInfo={NSDebugDescription=Unable to convert hex escape sequence (no high character) to UTF8-encoded character.
看到一篇来自Umer Mansoor的文章《The char Type in Java is Broken》(原文https://codeahoy.com/2016/05/08/the-char-type-in-java-is-broken/ ),标题就很炸人。说的是Java的char存储位数的问题。看到其中一段话:
char uses 16 bits to store Unicode characters that fall in the 0 - 65,535 which isn’t enough to store all Unicode characters anymore. You might think: Gee, 65,535 is plenty already. I’ll never use that many. That’s true. But your users will. And when they send you a character that requires more than 16 bits, like these emojis , the char methods like someString.charAt(0) or someString.substring(0,1) will break and give you only half the code point. And the worst part is that the compiler won’t even complain. Recently, a fellow developer told me that their “North American users” started complaining that the chat nicknames and messages “aren’t displaying properly”. After a lot of grief, they found the issue and had to undo all char manipulation in their software to handle emojis and other cool characters. (Use codePointAt(index)instead which returns an int that will fit all Unicode characters in existence.)