判断字符串中是否包含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. C# Winform 使用Application.Exit重新启动应用程序example

    Application.Exit会在所有前台线程退出后,退出应用, Environment.Exit则立即终止进程,相比之下Environment.Exit更狠些 private static voi ...

  2. Transaction And Lock--存在嵌套事务吗?

    在很多编程语言中,可以实现嵌套,但在TSQL中,可以实现嵌套事务吗? 答案:不可以 虽然我们可以写如下code: CREATE TABLE #TB1 ( ID INT ) --创建事务1 BEGIN ...

  3. MicroPython (一)点亮我的Led

    工具 : putty F429Discovery 开发板 Notepad++ 注意:不知道为什么 其他的终端工具有问题,推荐 putty 基本没有发现问题 putty 实时调试 使用putty 打开U ...

  4. unable browse url when InfoPath Convert to Connection File

    You must actived the windows feature "Desktop Experience" on the server : http://blogs.tec ...

  5. 转载:各种SQRT大比拼

    很有趣的文章: http://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi

  6. 适用于Java的嵌入式脚本语言

    此文已由作者赵昕授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. fakescript 轻量级嵌入式脚本语言 https://github.com/esrrhs/fakescr ...

  7. IO模型《六》IO模型比较分析

    IO模型比较分析 到目前为止,已经将四个IO Model都介绍完了.现在回过头来回答最初的那几个问题:blocking和non-blocking的区别在哪,synchronous IO和asynchr ...

  8. OCP 12c最新考试题库及答案(071-2)

    2019-02-12 16:23:54   2.(4-7) choose the best answer:You need to display the first names of all cust ...

  9. OCP2018最新题库,052新题库及答案整理-25题

    25.Which is true about logical and physical database structures? (Choose the best answer) A. An undo ...

  10. noip提高组模拟赛(QBXT)T2

    T2count题解 [ 问题描述]: 小 A 是一名热衷于优化各种算法的 OIER,有一天他给了你一个随机生成的 1~n 的排列, 并定 义区间[l,r]的价值为: \[ \huge C_{l,r}= ...