判断字符串中是否包含Emoji表情代码:

+ (BOOL)stringContainsEmoji:(NSString *)string

{

__block BOOL returnValue = 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) {

returnValue = YES;

}

}

} else if (substring.length > 1) {

const unichar ls = [substring characterAtIndex:1];

if (ls == 0x20e3) {

returnValue = YES;

}

} else {

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

returnValue = YES;

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

returnValue = YES;

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

returnValue = YES;

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

returnValue = YES;

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

returnValue = YES;

}

}

}];

return returnValue;

}

判断字符串中是否包含Emoji表情代码的更多相关文章

  1. [C#]判断字符串中是否包含中文

    关键代码: /// <summary> /// 判断字符串中是否包含中文 /// </summary> /// <param name="str"&g ...

  2. Node.js之判断字符串中是否包含某个字符串

    server.txt内容如下: 阿里云服务器 关于应用场景,就不多说了,字符串是不论是后端开发还是前端开发等,都是要经常打交道了. test.js(node.js代码,只要被本地装了node.js环境 ...

  3. PHP判断字符串中是否包含指定字符串,支持中文哦

    RT,随手写的 /** * 判断字符串中是否包含指定字符串 * @var source 源字符串 * @var target 要判断的是否包含的字符串 * @return bool */ functi ...

  4. 判断字符串中是否有SQL攻击代码

    判断一个输入框中是否有SQL攻击代码 public const string SQLSTR2 = @"exec|cast|convert|set|insert|select|delete|u ...

  5. java判断字符串中是否包含中文 过滤中文

    package com.test; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test ...

  6. java 判断字符串中是否包含中文并过滤掉中文

      java判断字符串中是否包含中文并过滤掉中文 CreateTime--2017年9月6日08:48:59 Author:Marydon 1.判断字符串中是否包含中文方法封装 /** * 判断字符串 ...

  7. python判断字符串中是否包含子字符串

    python判断字符串中是否包含子字符串 s = '1234问沃尔沃434' if s.find('沃尔沃') != -1:     print('存在') else:     print('不存在' ...

  8. php字符串查找函数 php查找字符串中出现的次数函数substr_count,判断字符串中是否包含另一个字符串函数strpos

    php字符串查找函数 php查找字符串中出现的次数函数substr_count,判断字符串中是否包含另一个字符串函数strpossubstr_count($haystack, $needle [,$o ...

  9. (算法)判断字符串中是否包含HelloWorld

    题目: 给定某字符串,判断该字符串中是否包含HelloWorld,出现HelloWorld不一定要连续,但顺序不变,如“HeByello,ByeWorByeld”就包含“HelloWorld”. 思路 ...

随机推荐

  1. 【MVC】分布视图带参数

    1.调用 <!--底部菜单--> @Html.Action(, itemTypeId = , itemId = ViewBag.Id }) 2.定义 public class ItemPu ...

  2. 知物由学 | 如何利用人工智能来对抗DDoS攻击?

    欢迎访问网易云社区,了解更多网易技术产品运营经验. "知物由学"是网易云易盾打造的一个品牌栏目,词语出自汉·王充<论衡·实知>.人,能力有高下之分,学习才知道事物的道理 ...

  3. 在一台服务器上搭建相对高可用HiveServer实践

    本文来自网易云社区 作者:刘杰 问题及原因 组里之前搭建了一个hiveserver提供给猛犸上的ETL程序调用,hiveserver隔三差五地挂掉重启,网上查了些资料,也咨询了猛犸那边维护hivese ...

  4. SnowFlake 生成全局唯一id

    public class SnowFlakeUtil { private long workerId; private long datacenterId; private long sequence ...

  5. leetcode 48. 旋转图像 java

    class Solution { public void rotate(int[][] matrix) { int n = matrix.length; for (int k = 0; k < ...

  6. (转)windows下VMware-workstation中安装CentOS

    windows下VMware-workstation中安装CentOS   windows下VMware-workstation中安装CentOS,可以分两部分,安装虚拟机和安装CentOS虚拟机.具 ...

  7. PHP初步:在Mac OS X Yosemite下搭建Apache+PHP+Mysql

    Mac OS X是基于unix的操作系统,很多软件都集成在系统中.所以,对于配置PHP的开发环境相对于windows和Linux更简单. 1. 启动Apache服务器 打开终端(terminal),查 ...

  8. iOS 本地时间、UTC时间、时间戳等操作、获取当前年月日

    //获得当前时间并且转为字符串 - (NSString *)dateTransformToTimeString { NSDate *currentDate = [NSDate date];//获得当前 ...

  9. 2016级算法第三次上机-G.Winter is coming

    904 Winter is coming 思路 难题.首先简化问题, \(n\) 个0与 \(m\) 个1排成一列,连续的0不能超过x个,连续的1不能超过y个,求排列方法数. 显然会想到这是动态规划. ...

  10. [转载]Flip an image in UIImageView using UIView transitionWithView

    View animations on the iPhone are wonderful. Used properly they will delight your users and help you ...