禁止输入表情的方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了禁止输入表情的方法相关的知识,希望对你有一定的参考价值。
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);
}
}
以上是关于禁止输入表情的方法的主要内容,如果未能解决你的问题,请参考以下文章