# Disable Emojis in Keyboard or Remove them from String?

**URL:** <https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202>\
**Category:** ionic-v3\
**Created:** [March 8, 2017, 12:19pm UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202 "2017-03-08T12:19:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon22300522](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon22300522](https://forum.ionicframework.com/u/anon22300522)\
**Post date:** [March 8, 2017, 12:19pm UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202/1 "2017-03-08T12:19:42Z")

</div>

Hi im facing the problem at the moment to store emojis in my sql database and i think a quick solution would be to disable them from using or remove them automatically from strings.  
Any way to do that?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [March 8, 2017, 10:42pm UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202/2 "2017-03-08T22:42:14Z")

</div>

I’m curious what the problem is with the database. If the text encoding is set up to properly handle Unicode, emojis shouldn’t pose a problem. In any event, [emoji-regex](https://github.com/mathiasbynens/emoji-regex) looks like it might be useful to you.

---

<div class="post-metadata">

**Author:** ![anon22300522](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon22300522](https://forum.ionicframework.com/u/anon22300522)\
**Post date:** [March 8, 2017, 10:46pm UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202/3 "2017-03-08T22:46:16Z")

</div>

Well i needed a fast solution of course i will use encoding then… i cant use unicode because my SQL Hoster doesnt allow to change the default utf8 … so encoding to base64 is the only way for me atm.

The solution with regex seems to be good ill try that out because i need to disable for usernames etc. Usernames shouldnt have emojis in my app and i want the user to dont use them.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [March 8, 2017, 10:51pm UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202/4 "2017-03-08T22:51:23Z")

</div>

> [@lukasrein97](#):
>
> i cant use unicode because my SQL Hoster doesnt allow to change the default utf8

That sounds weird to me, because UTF-8 _is_ capable of storing Unicode. That’s its entire purpose.

---

<div class="post-metadata">

**Author:** ![anon22300522](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon22300522](https://forum.ionicframework.com/u/anon22300522)\
**Post date:** [March 9, 2017, 6:58am UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202/6 "2017-03-09T06:58:22Z")

</div>

@rapropos So according to this tutorial: [https://mathiasbynens.be/notes/mysql-utf8mb4](https://mathiasbynens.be/notes/mysql-utf8mb4) i have to set up my SQL Server to this:

```
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+--------------------------+--------------------+

```

To get this settings you also have to modifie the SQL Config like this:

```
[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

```

And this is my Problem because my SQL Hoster dont provide me the Config of my SQL Server. So i cant modifiy it.  
So for me my SQL Server looks now like this:

```
character_set_client utf8
character_set_connection utf8
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
collation_connection utf8_general_ci
collation_database utf8mb4_unicode_ci
collation_server latin1_swedish_ci

```

As you can see only the database itselfe is set to utf8mb4…  
So if i insert Emojis now i only get “?” in my Database.  
Thas why i only can encode it to base64 at the moment and save it as base64.  
Im using MySQL 5.5 at the moment.

---

<div class="post-metadata">

**Author:** ![anon22300522](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon22300522](https://forum.ionicframework.com/u/anon22300522)\
**Post date:** [March 20, 2017, 1:18pm UTC](https://forum.ionicframework.com/t/disable-emojis-in-keyboard-or-remove-them-from-string/82202/7 "2017-03-20T13:18:02Z")

</div>

for all others i give you a hint if you want to remove emojis from strings use ng-pattern combined with a regex witch filters all utf16 characters. only allow utf8 and you are good to go 🙂
