emoji

Convert emoji to hex value using Swift

我的梦境 提交于 2019-12-20 05:02:07
问题 I'm trying to convert emojis in hex values, I found some code online to do it but it's only working using Objective C, how to do the same with Swift? 回答1: This is a "pure Swift" method, without using Foundation: let smiley = "😊" let uni = smiley.unicodeScalars // Unicode scalar values of the string let unicode = uni[uni.startIndex].value // First element as an UInt32 print(String(unicode, radix: 16, uppercase: true)) // Output: 1F60A Note that a Swift Character represents a "Unicode grapheme

Emoji's cause Express server to crash

旧时模样 提交于 2019-12-20 03:23:35
问题 I am trying to create a POST with an emoji to my Express endpoint: curl --data '{"x": 10, "y":10, "z":10, "message": "😋", "userToken": "Marine"}' --header "Content-Type:application/json" localhost:3000/api/messages For some reason this crashes my server: SyntaxError: Unexpected token at Object.parse (native) at parse (/Users/user/Documents/uncovery/node_modules/body-parser/lib/types/json.js:84:17) at /Users/user/Documents/uncovery/node_modules/body-parser/lib/read.js:102:18 at IncomingMessage

Encode a high code point (> U+FFFF) to HTML entities

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 02:38:14
问题 I have an input string (URL-encoded): %F0%9F%98%8E which decoded is the emoji "😎". How can I convert this to the HTML-Code 😎 ? http://unicode.online-toolz.com/tools/unicode-html-entities-convertor.php this site is doing exactly what I need. 回答1: <?php function mb_ord($char, $encoding = 'UTF-8') { if ($encoding === 'UCS-4BE') { list(, $ord) = (strlen($char) === 4) ? @unpack('N', $char) : @unpack('n', $char); return $ord; } else { return mb_ord(mb_convert_encoding($char, 'UCS-4BE', $encoding),

Emoji in Matplotlib figures on OS X

泪湿孤枕 提交于 2019-12-19 10:32:15
问题 I have an exotic task for Matplpoltlib for which I need to display emoji inside labels. I am using OS X, so there is a good system-wide support of emoji. However, things do not work out with Matplotlib: currently, emoji get displayed as empty boxes. I am using Python 3, so Unicode should not be a problem. Thank you 😀 回答1: The idea behind it is not very difficult but in order to get it to be displayed (at least on ubunto) it gave me some hard time as not all fonts support emoji. I shall

Emoji in Matplotlib figures on OS X

烂漫一生 提交于 2019-12-19 10:32:12
问题 I have an exotic task for Matplpoltlib for which I need to display emoji inside labels. I am using OS X, so there is a good system-wide support of emoji. However, things do not work out with Matplotlib: currently, emoji get displayed as empty boxes. I am using Python 3, so Unicode should not be a problem. Thank you 😀 回答1: The idea behind it is not very difficult but in order to get it to be displayed (at least on ubunto) it gave me some hard time as not all fonts support emoji. I shall

How does Facebook encode emoji in the json Graph API?

元气小坏坏 提交于 2019-12-19 09:47:40
问题 Does anyone know how Facebook encodes emoji with high-surrogate pairs in the Graph API? Low surrogate pairs seem fine. For example, ❤️ (HEAVY BLACK HEART, though it is red in iOS/OSX, link to image if you can't see the emoji) comes through as \u2764\ufe0f which appears to match the UTF-16 hex codes / "Formal Unicode Notation" shown here at iemoji.com. And indeed, in Ruby when parsing the JSON output from the API: ActiveSupport::JSON.decode('"\u2764\ufe0f"') you correctly get: "❤️" However, to

Python3 emoji characters as unicode

↘锁芯ラ 提交于 2019-12-19 09:09:32
问题 I have a string in python3 that has emojis in it and I want to treat the emojis as their unicode representation. I need to do some manipulation on the emoji in this format. s = '😬 😎 hello' This treats each emoji as its own character such that len(s) == 9 && s[0] == 😬 I want to be change the format of the string so that it is in unicode points such that s = '😬 😎 hello' u = to_unicode(s) # Some function to change the format. print(u) # '\ud83d\ude2c \ud83d\ude0e hello' u[0] == '\ud83d' and u[1]

Display Emoji in Python's console

坚强是说给别人听的谎言 提交于 2019-12-19 08:55:18
问题 I wonder if it's possible to print Emojis in a Python 3 console on Windows. Actually, to avoid the following error: codec can't encode character '\U0001f44d' in position 10: character maps to <undefined> I've used: import emoji as moji print(moji.emojize('Python is :thumbsup:', use_aliases=True).encode('unicode- escape')) which is, as expected , printing the right character:U0001f44d without any exception . 回答1: The Windows command prompt has a lot of limitations with regards to Unicode

Rendering Emoji with PIL

萝らか妹 提交于 2019-12-19 05:56:10
问题 I am trying to make images out of tweets, however some of them contain Emojis. I am using PIL to render my images and the Symbola font. The text is in unicode utf-8 encoding and the Symbola font does include the emojis. Here is an abridged version of the code: from PIL import Image, ImageFont, ImageDraw text = u"\U0001f300" #CYCLONE emoji image = Image.new("RGBA", (100,100), (255,255,255)) font = ImageFont.truetype("Symbola.ttf", 60, encoding='unic') draw = ImageDraw.Draw(image) draw.text((0

Android Get Country Emoji Flag Using Locale

怎甘沉沦 提交于 2019-12-19 05:44:15
问题 I have seen that since Lollipop , Android has built in Emoji flags for different countries. Is it possible to use the devices locale to retrieve the Emoji flag for that country? I wanted to insert the Emoji flag into a TextView which contains the user's location. 回答1: I was looking for that too but I don't think it's possible yet. Have a look here: http://developer.android.com/reference/java/util/Locale.html No mentioning about flags. _ Alternately you can check the answer here: Android