All Projects → onanying → emoji-helper-php

onanying / emoji-helper-php

Licence: other
去除过滤emoji表情、判断是否包含emoji表情,输出emoji表情的16进制字符串,对于没有使用utf8mb4编码数据库的项目,这个必不可少

Programming Languages

PHP
23972 projects - #3 most used programming language

Labels

Projects that are alternatives of or similar to emoji-helper-php

EmojiRunner
Search for emojis in Krunner and copy/paste them
Stars: ✭ 33 (+13.79%)
Mutual labels:  emoji
apple-emoji-linux
Apple Color Emoji for Linux
Stars: ✭ 392 (+1251.72%)
Mutual labels:  emoji
hashflags-function
⚡ A collection of Azure functions related to Twitter hashflags
Stars: ✭ 15 (-48.28%)
Mutual labels:  emoji
purescript-emo8
🍠 A functional 2D game engine that can create emoji games.
Stars: ✭ 47 (+62.07%)
Mutual labels:  emoji
ember-emojione
EmojiOne helper and components for your Ember App
Stars: ✭ 16 (-44.83%)
Mutual labels:  emoji
vemdezapbe.be
Vem de zap bb 😏😊😂
Stars: ✭ 33 (+13.79%)
Mutual labels:  emoji
EmoticonsBoard
Function keyboard and emotions. Android表情键盘,可动态更新表情。
Stars: ✭ 31 (+6.9%)
Mutual labels:  emoji
EmojiText
This is a EmojiText solution for Unity3D UI
Stars: ✭ 74 (+155.17%)
Mutual labels:  emoji
slack-emoji-import
Simple bulk emoji importer for slack
Stars: ✭ 35 (+20.69%)
Mutual labels:  emoji
emojifont
🍭Emoji and fontawesom in both base and ggplot2 graphics
Stars: ✭ 61 (+110.34%)
Mutual labels:  emoji
rafiki-zsh
👀👻 A zsh friend to watch over you.
Stars: ✭ 50 (+72.41%)
Mutual labels:  emoji
Emoji-Log-VSCode
Emoji-Log VSCode Extension — An Emoji Git commit log messages spec standard. [ 📦👌🐛📖🚀🤖 ‼️]
Stars: ✭ 44 (+51.72%)
Mutual labels:  emoji
a11y-react-emoji
⚛️ An accessible Emoji component for React applications
Stars: ✭ 69 (+137.93%)
Mutual labels:  emoji
spacymoji
💙 Emoji handling and meta data for spaCy with custom extension attributes
Stars: ✭ 174 (+500%)
Mutual labels:  emoji
EmojiConverter
Android Library for EditText
Stars: ✭ 35 (+20.69%)
Mutual labels:  emoji
slack-emoji-kr
한글을 활용한 슬랙 커스텀 이모지
Stars: ✭ 33 (+13.79%)
Mutual labels:  emoji
emojix
Simple emoji library for Elixir 💩
Stars: ✭ 21 (-27.59%)
Mutual labels:  emoji
FacebookChatStatistics
Statistics of any Facebook Messenger conversation
Stars: ✭ 49 (+68.97%)
Mutual labels:  emoji
emot
Open source Emoticons and Emoji detection library: emot
Stars: ✭ 178 (+513.79%)
Mutual labels:  emoji
emoji-to-scale
Your favorite emojis. To scale.
Stars: ✭ 334 (+1051.72%)
Mutual labels:  emoji

emoji_helper.php

去除过滤emoji表情、判断是否包含emoji表情,输出emoji表情的16进制字符串;对于没有使用utf8mb4编码数据库的项目,如果存入4字节的emoji表情,数据库会报错,只能选择将4字节的字符剔除。

使用说明

剔除字符串中的emoji表情

3个字节的emoji无法剔除, 比如讯飞输入法的emoji表情,正常的emoji表情都为4个字节,比如iOS的emoji表情

$text = emoji_reject($text);

判断字符串是否包含emoji表情

if(emoji_test($text)){
	
}

将emoji表情的16进制输出为字符串

echo emoji_print($emoji);

武林秘籍 (正则)

PHP与js的正则不同,是因为js使用的是ucs-2编码

PHP Sample

function emoji_test($text)
{
	$emoji = "/[\u010000-\u10FFFF]/g";  // 4字节utf-16 = emoji
	return preg_match($emoji, $text);
}

JavaScript Sample

function emoji_test(text)
{
	var emoji = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;  // 4字节utf-16 = emoji
	return emoji.test(text);
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].