码迷,mamicode.com
首页 > 其他好文 > 详细

禁止输入表情的方法

时间:2017-04-10 16:50:01      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:rom   har   nbsp   bool   location   pair   tor   ati   sel   

static NSCharacterSet *_variationSelectors;
_variationSelectors = [NSCharacterSet characterSetWithRange:NSMakeRange(0xFE00, 16)];

 

- (BOOL)isEmoji:(NSString *)string{
if ([string rangeOfCharacterFromSet: _variationSelectors].location != NSNotFound) {
return YES;
}

const unichar high = [string characterAtIndex: 0];
// Surrogate pair (U+1D000-1F9FF)
if (0xD800 <= high && high <= 0xDBFF) {
const unichar low = [string characterAtIndex: 1];
const int codepoint = ((high - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;

return (0x1D000 <= codepoint && codepoint <= 0x1F9FF);

// Not surrogate pair (U+2100-27BF)
} else {
return (0x2100 <= high && high <= 0x27BF);
}
}

禁止输入表情的方法

标签:rom   har   nbsp   bool   location   pair   tor   ati   sel   

原文地址:http://www.cnblogs.com/walkingzmz/p/6689517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!