Home Web Front-end HTML Tutorial How to solve the bug that emoji expressions cannot be sent on the front end

How to solve the bug that emoji expressions cannot be sent on the front end

Nov 27, 2017 pm 02:42 PM
emoji expression solve

When I was doing mobile development before, there was a function to post comments that needed to be implemented. Although this function is relatively simple to implement, when I tested it, I said that the bug that the emoji that comes with the phone failed to send always appeared. So today I will bring you the solution to this BUG

1. Change the database format in the background

Execute the sql statement to change the encoding format of the database to utf8mb4 storage format, this 4-byte The UTF-8 storage format is perfectly compatible with the previous 3-byte storage format, and can directly store emoji expressions. This is the most perfect solution.

2. Use base-64 encoding

For example, you can use base-encode to encode emoji expressions and then store them in UTF-8. Just decode them when you take them out, but I have not tried it.

3. Get rid of emoji expressions

Kill it violently, I guess the PM will not agree to do this

4. Front-end processing

It is to use a third-party plug-in to convert the input emoji into a span tag and assign it the corresponding class, find a lot of emoji and expression pictures, and when sending them to the background, they send span expressions, which can be stored in the background. The advantage of this is that the display will be the same on all devices and will not cause any problems. Ambiguity, of course, the disadvantage is that emoji expressions are being updated. It is possible that the emoji expression image library you find is incomplete, and some expressions cannot be displayed on the page. This requires regular maintenance.

Recommend a more useful plug-in library github.com/node-module…

How to use: First download the emoji plug-in

<link href="http://cdn.staticfile.org/emoji/0.2.2/emoji.css" rel="stylesheet" type="text/css" />
<script src="http://cdn.staticfile.org/emoji/0.2.2/emoji.js"></script>
Copy after login

Map these two code libraries. This plug-in does not need to rely on the jquery library at all

Connect It will be even simpler

var text = document.querySelector('emojiText');
cosnoel.log(jEmoji. unifiedToHTML(text.value))
Copy after login

If you use commenJS specification

$ npm install emoji
var emoji = require('emoji');
console.log('
Copy after login

The above is the detailed content of How to solve the bug that emoji expressions cannot be sent on the front end. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to Fix Steam Error Code 118 How to Fix Steam Error Code 118 Feb 19, 2024 pm 05:56 PM

How to Fix Steam Error Code 118

Solution to the problem that Win11 system cannot install Chinese language pack Solution to the problem that Win11 system cannot install Chinese language pack Mar 09, 2024 am 09:48 AM

Solution to the problem that Win11 system cannot install Chinese language pack

How to solve steam error code E20 How to solve steam error code E20 Feb 19, 2024 pm 09:17 PM

How to solve steam error code E20

Five tips to teach you how to solve the problem of Black Shark phone not turning on! Five tips to teach you how to solve the problem of Black Shark phone not turning on! Mar 24, 2024 pm 12:27 PM

Five tips to teach you how to solve the problem of Black Shark phone not turning on!

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? Mar 22, 2024 am 08:06 AM

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting?

The driver cannot be loaded on this device. How to solve it? (Personally tested and valid) The driver cannot be loaded on this device. How to solve it? (Personally tested and valid) Mar 14, 2024 pm 09:00 PM

The driver cannot be loaded on this device. How to solve it? (Personally tested and valid)

How to solve Chinese garbled characters in Linux How to solve Chinese garbled characters in Linux Feb 21, 2024 am 10:48 AM

How to solve Chinese garbled characters in Linux

Share the method to solve the problem that PyCharm cannot be opened Share the method to solve the problem that PyCharm cannot be opened Feb 22, 2024 am 09:03 AM

Share the method to solve the problem that PyCharm cannot be opened

See all articles