# Support emoji in CJK context without spaces

**URL:** https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717
**Category:** Feature
**Created:** [November 25, 2018, 12:54pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717 "2018-11-25T12:54:53Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![channing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/channing/32/125299_2.png) [@channing](https://meta.discourse.org/u/channing)
#### Post date: [November 25, 2018, 12:54pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/1 "2018-11-25T12:54:53Z")

</div>

Spaces are required for emoji to display correctly in a CJK (Chinese, Japanese, and Korean) language context. For example,

`你好:hugs:`  
displays  
你好:hugs:

You have to add a space here:  
`你好 :hugs:`  
displays  
你好 🤗

_Spaces are rarely used in CJK_, and most users don’t know about this issue so they end up with some untranslated emoji in their posts. It would be really great if you can make a special rule for CJK and emoji 👍

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 25, 2018, 9:01pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/2 "2018-11-25T21:01:33Z")

</div>

Also raised a few times before

> [@Suggestion: Spaces before emoji's when chosen from picker](https://meta.discourse.org/t/suggestion-spaces-before-emojis-when-chosen-from-picker/71163):
>
> Emoji’s current require a space before the colon in order to be recognized: Hello world:smile: (no space before emoji is NOT OK) Hello world!smile (non-word character before emoji is OK) Hello world smile (space before emoji is OK) Hello :smile:world (no space after is OK) It is a little cumbersome to always have to remember to type a space before adding an emoji. The situation is less of a problem in most languages because of punctuation and words being naturally separated…

> [@Automatically add a space before the emoji if the user is typing Chinese and uses emoji picker](https://meta.discourse.org/t/automatically-add-a-space-before-the-emoji-if-the-user-is-typing-chinese-and-uses-emoji-picker/83285):
>
> Hi Discourse team: I have been using Discourse for 4 years and love the modern design and quick update. Thank you! Recently I have noticed some issues in my [forum](http://iosre.com), that in China, we seldom use spaces like you do in English, so basically every emoji from emoji picker is screwed like this: 呵呵:thinking: Which is annoying and confuses most Chinese users. Can you think of a way to improve the Chinese user experience? Thank you! Yinglu

And a few others, open to changing this in CJK

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [November 25, 2018, 10:27pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/3 "2018-11-25T22:27:07Z")

</div>

@nbianca can you add a new site setting `require_punct_before_emoji` that is enabled by default but disabled for CJK locales?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 25, 2018, 10:43pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/5 "2018-11-25T22:43:26Z")

</div>

They can simply insert the actual Unicode emoji via their native OS emoji picker. I am afraid this might be a giant can of worms @zogstrip so I am not sure if we should take it on right now.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [November 25, 2018, 10:56pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/6 "2018-11-25T22:56:23Z")

</div>

This will only affect CJK locales and is one click away to be disabled if needed.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 25, 2018, 10:57pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/7 "2018-11-25T22:57:08Z")

</div>

Ok, as long as it can be tightly scoped!

---

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [November 25, 2018, 10:59pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/8 "2018-11-25T22:59:16Z")

</div>

That’s good point. I use a IM which allows me to insert Emoji. As long as it’s shown as emoji in source view, users won’t notice the syntax at all.

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/1/61d0b955c0dd25d310b2207cc821e265af7180d6.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 25, 2018, 11:12pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/9 "2018-11-25T23:12:33Z")

</div>

Scoping wise I think we need to go with the ULTRA simple… if you see a `:` assume an emoji is coming up when this is enabled.

At the moment we have:

> <https://github.com/discourse/discourse/blob/93d4281706ab9a038e67963d659ef582efbf5504/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6#L65-L73>

Meaning if you see a space or a punctuation prior to `:` it can be an emoji.

The new algorithm for CJK with the client setting `enable_inline_emoji_translation` would be to remove that restriction. Basically if the site setting is enabled that whole if statement is skipped.

The alternative I am not too keen about is adding any kind of regex test cause it will impact performance on the MD engine. (eg: [Unicode Kanji Code Table](http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml))

Even the reverse is hard, it is easy to detect “letter/number” but then we would also need to deal with Vietnamese and other heavily accented languages, so building this in is just too expensive.

We also need to make sure the emoji autocompleter is aware of this if possible.

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [November 26, 2018, 2:33pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/10 "2018-11-26T14:33:41Z")

</div>

Implemented in

[https://github.com/discourse/discourse/pull/6669](https://github.com/discourse/discourse/pull/6669)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [January 5, 2019, 4:39pm UTC](https://meta.discourse.org/t/support-emoji-in-cjk-context-without-spaces/102717/11 "2019-01-05T16:39:00Z")

</div>


