博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
输入框禁止表情
阅读量:7088 次
发布时间:2019-06-28

本文共 1255 字,大约阅读时间需要 4 分钟。

#pragma mark-禁止表情

BOOL emoji=[self isContainsEmoji:输入框内容];

- (BOOL)isContainsEmoji:(NSString *)string {

__block BOOL isEomji = NO;

[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:

^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {

const unichar hs = [substring characterAtIndex:0];

if (0xd800 <= hs && hs <= 0xdbff) {

if (substring.length > 1) {

const unichar ls = [substring characterAtIndex:1];

const int uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;

if (0x1d000 <= uc && uc <= 0x1f77f) {

isEomji = YES;

}

}

} else if (substring.length > 1) {

const unichar ls = [substring characterAtIndex:1];

if (ls == 0x20e3) {

isEomji = YES;

}

} else {

if (0x2100 <= hs && hs <= 0x27ff && hs != 0x263b) {

isEomji = YES;

} else if (0x2B05 <= hs && hs <= 0x2b07) {

isEomji = YES;

} else if (0x2934 <= hs && hs <= 0x2935) {

isEomji = YES;

} else if (0x3297 <= hs && hs <= 0x3299) {

isEomji = YES;

} else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b || hs == 0x2b50|| hs == 0x231a ) {

isEomji = YES;

}}

}];

return isEomji;

}

转载于:https://juejin.im/post/5a3b6dd75188257d6929c31d

你可能感兴趣的文章
python2.0_s12_day19_前端模版使用
查看>>
PHP json_decode object时报错Cannot use object of type stdClass as array
查看>>
hibernate一对一外键双向关联
查看>>
SharePoint 2013 同步FBA认证用户
查看>>
二叉树的遍历实现
查看>>
Sublimetext 3 经常使用插件
查看>>
Educational Codeforces Round 11 C. Hard Process 二分
查看>>
Android Camera 使用一例,视频聊天app
查看>>
区块链代币(Token)笔记 — — 术语
查看>>
python 解析json讲解(demjson)
查看>>
Apache优化:修改最大并发连接数
查看>>
Golang--Hello World
查看>>
《火球——UML大战需求分析》(第1章 大话UML)——1.4 如何学好UML?
查看>>
某IT校招笔试
查看>>
分布式系统介绍-PNUTS
查看>>
归并分类
查看>>
php生成图片验证码
查看>>
Android Studio git 版本回退到最新的版本
查看>>
C#中使用Log4net日志输出到本地文件、Textbox或Listview
查看>>
Java系列:JVM中的OopMap(zz)
查看>>