emoji

使mysql支持emoji

我的未来我决定 提交于 2019-12-04 13:47:36
在微信开发过程中,有些用户的昵称是特殊表情,导致服务器端存储时发生错误: Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x84' for column 'review' at row 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) at

让Mysql支持Emoji表情

a 夏天 提交于 2019-12-04 13:47:05
Java 获取到微信端传递过来的Emoji表情插入MySQL之后报错 , 错误信息如下 java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1662) at com.mysql.jdbc

Emoji and other unicode characters not appearing correctly in Angular

懵懂的女人 提交于 2019-12-04 13:39:42
问题 I have a web app that uses messages from Twitter, for example. A feed of JSON is used to build a list of messages, but characters such as 🙏👍👊 are displaying as question marks in a diamond. The element looks like this: <div class="inner-message" ng-bind-html="unit.caption_text | linky:'_blank'"></div> When I view the JSON url in Firefox and Chrome, these display fine. Sample of head: <!DOCTYPE html> <html class="wf-opensans-n4-active wf-active" lang="en"> <head> <meta charset="utf-8"> One

Swift - Replacing emojis in a string with whitespace

巧了我就是萌 提交于 2019-12-04 12:32:49
I have a method that detects urls in a string and returns me both the urls and the ranges where they can be found. Everything works perfectly until there are emojis on the string. For example: "I'm gonna do this callenge as soon as I can swing again 😂😂😂\n http://youtu.be/SW_d3fGz1hk" Because of the emojis, the url extracted from the text is http://youtu.be/SW_d3fGz1 instead of http://youtu.be/SW_d3fGz1hk . I figured that the easiest solution was to just replace the emojis on the string with whitespace characters (cause I need the range to be correct for some text styling stuff). Problem is,

Python - replace unicode emojis with ASCII characters

对着背影说爱祢 提交于 2019-12-04 11:29:45
I have an issue with one of my current weekend projects. I am writing a Python script that fetches some data from different sources and then spits everything out to an esc-pos printer. As you might imagine pos printers don't exactly like emojis... So text like this: 可爱!!!!!!!!😍😍😍😍😍😍😍😝 gives me this character string: '\u53ef\u7231!!!!!!!!\U0001f60d\U0001f60d\U0001f60d\U0001f60d\U0001f60d\U0001f60d\U0001f60d\U0001f61d' The result that comes out of the printer is quite different than what I would like of course. So I need to replace these non-ASCII characters with something else. I don't really

UILabel not showing emoji

拈花ヽ惹草 提交于 2019-12-04 11:06:48
I'm facing a problem about displaying emoji in a UILabel. I get this data from a web service (i cannot change the way i get the data) : This value is from the debugger : __NSCFString * @"emoji \\ud83d\\ude1b\\ud83d\\ude1d" 0x000000017405ea80 Value from NSLog : emoji \ud83d\ude1b\ud83d\ude1d if i assign this value to my UILabel text property i get on the screen : emoji \ud83d\ude1b\ud83d\ude1d I tried to encode and decode the string using : NSData *data = [string dataUsingEncoding:NSNonLossyASCIIStringEncoding]; NSString *dataValue = [[NSString alloc] initWithData:data encoding

Printing family emoji, with U+200D zero-width joiner, directly, vs via list

风流意气都作罢 提交于 2019-12-04 09:53:31
I have found some unexpected differences when printing, via print , a string with a family emoji directly, and when it's in a list. The below program family = '👨‍👩‍👧‍👧' print(family) print([family]) outputs 👨‍👩‍👧‍👧 ['👨\u200d👩\u200d👧\u200d👧'] when I would expect it to output 👨‍👩‍👧‍👧 ['👨‍👩‍👧‍👧'] Another case of multi-character glyph man_with_skin_tone_modifier = '👨🏿' print(man_with_skin_tone_modifier) print([man_with_skin_tone_modifier]) outputs as I expect: 👨🏿 ['👨🏿'] Why is this? Context: I discovered this while writing the answer for https://stackoverflow.com/a/49930688/1319998 , and it's

Is it possible to write a Swift function that replaces only part of an extended grapheme cluster like 👩‍👩‍👧‍👧?

核能气质少年 提交于 2019-12-04 09:07:22
问题 I want to write a function that could be used like this: let 👩‍👩‍👧‍👦 = "👩‍👩‍👧‍👧".replacingFirstOccurrence(of: "👧", with: "👦") Given how odd both this string and Swift's String library are, is this possible in Swift? 回答1: Using the range(of:options:range:locale:) the solution became quite concise: extension String { func replaceFirstOccurrence(of searchString: String, with replacementString: String) -> String { guard let range = self.range(of: searchString, options: .literal) else { return

MySql 怎么存取 Emoji

空扰寡人 提交于 2019-12-04 07:56:06
01、前言 Emoji 在我们生活中真的是越来越常见了,几乎每次发消息的时候不带个 Emoji,总觉得少了点什么,似乎干巴巴的文字已经无法承载我们丰富的感情了。对于我们开发者来说,如何将 Emoji 存入 MySql 数据库或者取出来,就变成了一种必须掌握的技能了。 Emoji 是一种图形符号,能够很直观地反应出某种文字含义。它让我想起远古时代的象形文字。 1 16.3 KB Emoji 其实是一个日语词(えもじ), E 表示"絵", moji 表示"文字";连在一起就是"絵文字",可以更形象化地表情达意。 02、糟糕 如果我们直接将 Emoji 表情存入数据库的话,通常会出现下面这个错误。 1 6.1 KB 因为数据库的字符编码一般是 utf8(支持的编码范围为 \u0000-\uFFFF ),而 Emoji 所在的编码范围是 \u1F601-\u1F64F ,超出 MySql 的边界了。 怎么解决这个问题呢? 03、utf8mb4 可以将 MySql 的字符集由 utf8 调整为 utf8mb4。utf8mb4 是 MySql 在 5.5.3 版本之后增加的一个编码方式,用来兼容四字节的 Unicode(包括 Emoji)。 理论上,utf8mb4 是 utf8 的超集,其中 mb4 是 most bytes 4 的意思,将字符集修改为“utf8mb4”,并不会对已有的

How to disable the emoji keyboard in iOS 7?

一个人想着一个人 提交于 2019-12-04 06:01:30
I wanted to disable the emoji keyboard programmatically. please let me know how can i do that ? I tried using following code, NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"]; [dict setObject:[NSNumber numberWithBool:NO] forKey:@"KeyboardEmojiEverywhere"]; But no luck ... :( You can simply set the property keyboardType of the UITextField or UITextView to UIKeyboardTypeASCIICapable. This disables the Emoji Keyboard for this UI element. This may not work in chinese how ever we have a workaround