<span id="Label3"></p><p><p>Text entrainment in app apps is a very common phenomenon. Even some more than 40-year-old Uncle-level users, also like in their own nickname to carry the expression, after the product operation found this phenomenon, completely subvert my world view.</p></p><p><p></p></p><p><p>In the background processing the expression time, I have encountered the following 3 questions:</p></p><p><p></p></p><strong><strong>1. expression in mysql storage</strong></strong><p><p></p></p><p><p>The UTF8 encoding of the expression, sometimes with 4 bytes, is not stored in the generic UTF encoding.</p></p><p><p></p></p><p><p>To see a common solution on the Internet is to upgrade MySQL to 5.5 and then change the character encoding to Utf8mb4_general_ci.</p></p><p><p></p></p><p><p>But the reality is, it is possible in the previous version of the app does not need to support emoticons, then the system has been operating for some time, then the MySQL upgrade and migration of data, the need for high operational costs, and a certain degree of risk, for example, before the migration of different MySQL versions need data synchronization between Ensure data consistency, and unexpected events may occur during the migration process, causing the service to Stop.</p></p><p><p></p></p><p><p>But in practice, I found that there is also a method for MySQL 5.1, that is, the type of the field containing the expression into a blob, yes, binary storage, so that it can be less than the change of Mysql.</p></p><p><p></p></p><strong><strong>2. Handling of expressions in text</strong></strong><p><p></p></p><p><p>Many times, if the text with the expression, then the processing of these words will be problematic, for example, if a User's nickname with emoticons, then how can I convert this nickname to pinyin? In the push APNs process, if the push text with the expression, push to the app side will also show Garbled.</p></p><p><p></p></p><p><p>In the app backend, there is a lot of need to deal with the expression in the Text. I met this problem, first found Https://github.com/iamcal/php-emoji This conversion expression of the class library, but found that the class library does not support the IOS6 after the new expression, finally no way, I wrote a crawler, the http/ Punchdrunker.github.io/iosemoji/table_html/ios6/index.html in the IOS6 after the new expression crawled out, and wrote a new class library and open source https://github.com/ newjueqi/converemojitostr, the role of this class library is to replace the words with a special character (the default is "#").</p></p><p><p></p></p><strong><strong>problems sending emoticons in 3.openfire causing disconnection</strong></strong><p><p></p></p><p><p>In openfire, if some special characters are sent (for example, some expressions are met), the connection to XMPP will be disconnected, which is caused by the following code problem:</p></p><p><p></p></p><p><p>Src\java\org\jivesoftware\openfire\net\mxparser.java</p></p><p><p></p></p><p><p></p></p><strong><strong>[java]</strong></strong>View Plaincopy <ol class="dp-j" start="1"> <li class="alt"><li class="alt"><span class="keyword">Protected <span class="keyword">Char more () <span class="keyword">throws ioexception, xmlpullparserexception {</span> </span></span></li></li> <li><li><span class="keyword">final <span class="keyword">char codepoint = <span class="keyword">Super.more (); <span class="comment">//note-this does not return a codepoint now, but simply a (single Byte) character! </span></span></span></span></li></li> <li class="alt"><li class="alt"><span class="keyword">if ((codepoint = = <span class="number">0x0) | | <span class="comment">//0x0 isn't allowed, but flash clients insist on sending this as the very first character of a Stream. We should stop allowing this codepoint after the first byte have been Parsed. </span></span></span></li></li> <li><li>(codepoint = = <span class="number">0x9) | | </span></li></li> <li class="alt"><li class="alt">(codepoint = = <span class="number">0xA) | | </span></li></li> <li><li>(codepoint = = <span class="number">0xD) | | </span></li></li> <li class="alt"><li class="alt">((codepoint >= <span class="number">0x20) && (codepoint <= <span class="number">0xd7ff)) | | </span></span></li></li> <li><li>((codepoint >= <span class="number">0xe000) && (codepoint <= <span class="number">0xFFFD)) | | </span></span></li></li> <li class="alt"><li class="alt">((codepoint >= <span class="number">0x10000) && (codepoint <= <span class="number">0x10ffff)) {</span> </span></li></li> <li><li><span class="keyword">return codepoint; </span></li></li> <li class="alt"><li class="alt">}</li></li> <li><li></li></li> <li class="alt"><li class="alt"><span class="keyword">throw <span class="keyword">New Xmlpullparserexception (<span class="string">"illegal XML character:" + integer.parseint (codepoint+<span class="string">"", <span class="number">16)); </span></span></span></span></span></li></li> <li><li>}</li></li> </ol><p><p><br><br></p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p>Because the special character is treated as an exception here, OpenFire is Disconnected.</p></p><p><p></p></p><p><p>Workaround:</p></p><p><p></p></p><strong><strong>[java]</strong></strong>View Plaincopy <ol class="dp-j" start="1"> <li class="alt"><li class="alt"><span class="annotation">@Override</span></li></li> <li><li><span class="keyword">protected <span class="keyword">Char more () <span class="keyword">throws ioexception, xmlpullparserexception {</span> </span> </span></li></li> <li class="alt"><li class="alt"><span class="keyword">final <span class="keyword">char codepoint = <span class="keyword">Super.more (); <span class="comment">//note-this does not return a codepoint now, but simply a (single Byte) character! </span></span></span></span></li></li> <li><li><span class="keyword">if ((codepoint = = <span class="number">0x0) | | <span class="comment">//0x0 isn't allowed, but flash clients insist on sending this as the very first character of a Stream. We should stop allowing this codepoint after the first byte have been Parsed. </span></span></span></li></li> <li class="alt"><li class="alt">(codepoint = = <span class="number">0x9) | | </span></li></li> <li><li>(codepoint = = <span class="number">0xA) | | </span></li></li> <li class="alt"><li class="alt">(codepoint = = <span class="number">0xD) | | </span></li></li> <li><li><span class="comment">//fix Some emotion</span></li></li> <li class="alt"><li class="alt">((codepoint >= <span class="number">0x20) && (codepoint <= <span class="number">0xFFFD)) | | </span></span></li></li> <li><li>((codepoint >= <span class="number">0x10000) && (codepoint <= <span class="number">0x10ffff)) {</span> </span></li></li> <li class="alt"><li class="alt"><span class="keyword">return codepoint; </span></li></li> <li><li>}</li></li> <li class="alt"><li class="alt"></li></li> <li><li><span class="keyword">throw <span class="keyword">New Xmlpullparserexception (<span class="string">"illegal XML character:" + integer.parseint (codepoint+<span class="string">"", <span class="number">16)); </span></span></span></span></span></li></li> <li class="alt"><li class="alt">}</li></li> </ol><p><p></p></p><p><p>Tips for dealing with emoticons in app backend</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service