+ (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;

}

iOS开发 判断字符串是不是表情的更多相关文章

  1. iOS开发 判断字符串是不是网址

    - (BOOL)isUrlString { NSString *emailRegex = @"[a-zA-z]+://.*"; NSPredicate *emailTest = [ ...

  2. IOS开发之显示微博表情

    在上一篇博客中山寨了一下新浪微博,在之后的博客中会对上一篇代码进行优化和重用,上一篇的微博请求的文字中有一些表情没做处理,比如带有表情的文字是这样的“我要[大笑],[得意]”.显示的就是请求的字符串, ...

  3. iOS开发 判断当前APP版本和升级

    从iOS8系统开始,用户可以在设置里面设置在WiFi环境下,自动更新安装的App.此功能大大方便了用户,但是一些用户没有开启此项功能,因此还是需要在程序里面提示用户的 方法一:在服务器接口约定对应的数 ...

  4. iOS开发之字符串比较

    Object-c中比较两个字符串是否相等时,应该用isEqualToString:而不能仅仅只是比较字符串的指针值. NSString *str1=@"hello 1";  NSS ...

  5. iOS开发JSON字符串和字典互转

    1.相关属性简述 NSJSONReadingOptions读取属性: typedef NS_OPTIONS(NSUInteger, NSJSONReadingOptions) { NSJSONRead ...

  6. iOS之判断字符串是否为空字符的方法

    -  (BOOL) isBlankString:(NSString *)string { if (string == nil || string == NULL) { return YES; } if ...

  7. iOS开发——常用字符串string相关方法和处理

    (持续更新中……) 1,四舍五入 2,剔除字符 3,拼接字符 4,字符个数和长度 5,字符串的比较 6,字符串的范围 7,字符串转Number类型

  8. iOS开发——判断邮箱格式

    //判断邮箱格式 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@ ...

  9. iOS开发——判断是否第一次启动

    在我们做项目的时候,判断是否是第一次启动,还是比较常用的,比如,欢迎界面,只是第一次启动需要的调查问卷等等,目的明确,方法很多,这里介绍一种简单的. 在你需要只有第一次启动才跳转的地方写上 if(![ ...

随机推荐

  1. Zend Studio集成Xdebug断点调试详解

    转自:http://www.softown.cn/post/115.html Xdebug是PHP开发中两个常用的断点调试工具之一(另一个为Zend Debugger). 现在,我们在Zend Stu ...

  2. ThinkPHP eq neq if 标签

    内置标签的使用方法 在action文件输出一个变量 $title="hello"; $this->assign('title',$title); 如果title变量的值等于& ...

  3. linux 帮助命令

    帮助命令 man(manual) 可以用来查看1 命令 2 配置文件 格式 man ls 1 查看命令 看第一行NAME 如果要看-l ,那么直接输入/-l 2 查看配置文件 man 查看配置文件信息 ...

  4. java中|与||,&与&&到底有什么区别呢?

    &是位运算符.&&是布尔逻辑运算符.在运行上,&两边的条件都要判断(不管前面的是ture还是false),而&&先判断前面的,若为false,则后面的不 ...

  5. 2016年11月3日 星期四 --出埃及记 Exodus 19:19

    2016年11月3日 星期四 --出埃及记 Exodus 19:19 and the sound of the trumpet grew louder and louder. Then Moses s ...

  6. POJ 1840 Eqs 暴力

      Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The ...

  7. Android-activity-intent

    package com.hanqi.myapplication; import android.content.ComponentName; import android.content.Intent ...

  8. Android 获取存储空间

    package com.example.getMem; import java.io.File; import android.os.Build;import android.os.Bundle;im ...

  9. 学习笔记TimePicker

    new TimePickerDialog(this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view ...

  10. C#中关键字ref修饰类对象或结构体[转]

    using System; using System.Collections.Generic; using System.Text; namespace CSharpTest { struct Dog ...