kurrik / twittergo

Twitter client library for go
Apache License 2.0
200 stars 31 forks source link

Emoji not working #2

Closed harperreed closed 10 years ago

harperreed commented 10 years ago

Emoji coming through the twitter API is not being passed correctly through twittergo, and thus is not rendering when displaying

For example:

   {"contributors":null,"coordinates":null,"created_at":"Thu Jul 24 01:25:36 +0000 2014","entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[{"id":529388090,"id_str":"529388090","indices":[0,15],"name":"Mrs Stig-Helmer ","screen_name":"isabelodelfelt"}]},"favorite_count":0,"favorited":false,"geo":null,"id":492118368036880384,"id_str":"492118368036880384","in_reply_to_screen_name":"isabelodelfelt","in_reply_to_status_id":492118366908596224,"in_reply_to_status_id_str":"492118366908596224","in_reply_to_user_id":529388090,"in_reply_to_user_id_str":"529388090","lang":"en","place":null,"retweet_count":0,"retweeted":false,"source":"\u003ca href=\"http://github.com/mroth\" rel=\"nofollow\"\u003eemojidoll\u003c/a\u003e","text":"@isabelodelfelt your unique emojidoll:\n    �� \n    �� \n������\n  ����","truncated":false,"user":{"contributors_enabled":false,"created_at":"Wed Jul 09 05:05:18 +0000 2014","default_profile":true,"default_profile_image":false,"description":"Tweet “@emojidoll me” to get your own unique emojidoll based on your twitter account. Over 15.6M possible combos. Made by @mroth.","entities":{"description":{"urls":[]}},"favourites_count":25,"follow_request_sent":false,"followers_count":1859,"following":false,"friends_count":1,"geo_enabled":false,"id":2612986777,"id_str":"2612986777","is_translation_enabled":false,"is_translator":false,"lang":"en","listed_count":18,"location":"","name":"emojidoll","notifications":false,"profile_background_color":"C0DEED","profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","profile_background_tile":false,"profile_banner_url":"https://pbs.twimg.com/profile_banners/2612986777/1405044183","profile_image_url":"http://pbs.twimg.com/profile_images/487405853293559808/pTrJCHYl_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/487405853293559808/pTrJCHYl_normal.png","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"protected":false,"screen_name":"emojidoll","statuses_count":8624,"time_zone":"Eastern Time (US \u0026 Canada)","url":null,"utc_offset":-14400,"verified":false}}

The good part:

   "text":"@isabelodelfelt your unique emojidoll:\n    �� \n    �� \n������\n  ����"

Not quite sure how to remedy this. I did some testing and other unicode seems to work fine (japanese language, etc).

kurrik commented 10 years ago

Thanks, I'll take a look.

harperreed commented 10 years ago

Thanks! I was diving in - but am rusty.

On Thu, Jul 24, 2014 at 2:14 PM, Arne Roomann-Kurrik < notifications@github.com> wrote:

Thanks, I'll take a look.

— Reply to this email directly or view it on GitHub https://github.com/kurrik/twittergo/issues/2#issuecomment-50064326.

Harper Reed t: @harper p: +1 (773) 469-7666

kurrik commented 10 years ago

That's what I get for rolling my own JSON decoder. For some reason Go doesn't want to unescape these correctly (or I'm going about it completely wrong) but I've added support here: https://github.com/kurrik/json/commit/f63ef626c5ffbfcd5dd5430c18c8b2eb14593c38

I've also added an example which fetches all of Twitter's sample emoji Tweets and prints them: https://github.com/kurrik/twittergo-examples/blob/master/emoji/main.go

selection_017

You'll need to update your json dependency, typically through go get -u github.com/kurrik/json (make sure to include the -u flag to pull the new version)

Let me know how that works for you!

harperreed commented 10 years ago

Worked! Thanks!

On Thu, Jul 24, 2014 at 6:29 PM, Arne Roomann-Kurrik < notifications@github.com> wrote:

That's what I get for rolling my own JSON decoder. For some reason Go doesn't want to unescape these correctly (or I'm going about it completely wrong) but I've added support here: kurrik/json@f63ef62 https://github.com/kurrik/json/commit/f63ef626c5ffbfcd5dd5430c18c8b2eb14593c38

I've also added an example which fetches all of Twitter's sample emoji Tweets and prints them: https://github.com/kurrik/twittergo-examples/blob/master/emoji/main.go

[image: selection_017] https://cloud.githubusercontent.com/assets/166424/3696103/ee1a6894-1388-11e4-99ab-786d45373bc5.png

You'll need to update your json dependency, typically through go get -u github.com/kurrik/json (make sure to include the -u flag to pull the new version)

Let me know how that works for you!

— Reply to this email directly or view it on GitHub https://github.com/kurrik/twittergo/issues/2#issuecomment-50091573.

Harper Reed t: @harper p: +1 (773) 469-7666