- (BOOL)df_containsEmoji
{
if ([self df_isFuckEmoji]) {
return YES;
}
const unichar high = [self characterAtIndex:0];
// Surrogate pair (U+1D000-1F77F)
if (0xd800 <= high && high <= 0xdbff) {
const unichar low = [self characterAtIndex: 1];
const int codepoint = ((high - 0xd800) * 0x400) + (low - 0xdc00) + 0x10000;
return (0x1d000 <= codepoint && codepoint <= 0x1f77f);
// Not surrogate pair (U+2100-27BF)
} else {
return (0x2100 <= high && high <= 0x27bf);
}
//
}
- (BOOL)df_isFuckEmoji
{
NSArray *digs = @[@"0️⃣",@"1️⃣",@"2️⃣",@"3️⃣",@"4️⃣",@"5️⃣",@"6️⃣",@"7️⃣",@"8️⃣",@"9️⃣",@"#️⃣",@"*️⃣",@"#⃣️",@"*️⃣",@"0⃣️",@"1⃣️",@"2⃣️",@"3⃣️",@"4⃣️",@"5⃣️",@"6⃣️",@"7⃣️",@"8⃣️",@"9⃣️"] ;
if([digs containsObject:self]){
return YES;
}
NSString *emoji = @"🤣🤑🤗🤓🤡🤠🤤🤔🤥🤐🤢🤧🤒🤕🤖🤝🤛🤜🤞🤘🤚🤙🤳🤶🤴🤵🤰🤦♀️🤦♂️🤷♀️🤷♂️🤛🏻🤜🏻🤞🏻🤘🏻🤚🏻🤙🏻🤳🏻🤶🏻🤴🏻🤵🏻🤰🏻🤦🏻♀️🤦🏻♂️🤷🏻♀️🤷🏻♂️🤸🏻♀️🤸🏻♂️🤾🏻♀️🤾🏻♂️🤽🏻♀️🤽🏻♂️🤹🏻♀️🤹🏻♂️🤛🏼🤜🏼🤞🏼🤘🏼🤚🏼🤙🏼🤳🏼🤶🏼🤴🏼🤵🏼🤰🏼🤦🏼♀️🤦🏼♂️🤷🏼♀️🤷🏼♂️🤸🏼♀️🤸🏼♂️🤾🏼♀️🤾🏼♂️🤽🏼♀️🤽🏼♂️🤹🏼♀️🤹🏼♂️🤛🏽🤜🏽🤞🏽🤘🏽🤚🏽🤙🏽🤳🏽🤶🏽🤴🏽🤵🏽🤰🏽🤦🏽♀️🤦🏽♂️🤷🏽♀️🤷🏽♂️🤸🏽♀️🤸🏽♂️🤾🏽♀️🤾🏽♂️🤽🏽♀️🤽🏽♂️🤹🏽♀️🤹🏽♂️🤛🏾🤜🏾🤞🏾🤘🏾🤚🏾🤙🏾🤳🏾🤶🏾🤴🏾🤵🏾🤰🏾🤦🏾♀️🤦🏾♂️🤷🏾♀️🤷🏾♂️🤸🏾♀️🤸🏾♂️🤾🏾♀️🤾🏾♂️🤽🏾♀️🤽🏾♂️🤹🏾♀️🤹🏾♂️🤛🏿🤜🏿🤞🏿🤘🏿🤚🏿🤙🏿🤳🏿🤶🏿🤴🏿🤵🏿🤰🏿🤦🏿♀️🤦🏿♂️🤷🏿♀️🤷🏿♂️🤸🏿♀️🤸🏿♂️🤾🏿♀️🤾🏿♂️🤽🏿♀️🤽🏿♂️🤹🏿♀️🤹🏿♂️🦊🦁🦆🦅🦉🦇🦄🦋🦎🦂🦀🦑🦐🦈🦌🦏🦍🦃🥀⭐️🥝🥑🥒🥕🥔🥜🥐🥖🧀🥚🥓🥞🥙🥗🥘🥛🥂🥃🥄🥅🥊🥋🤺🤼♀️🤼♂️🤸♀️🤸♂️🤾♀️🤾♂️🤽♀️🤽♂️🥇🥈🥉🤹♀️🤹♂️🥁㊙️㊗️⭕️‼️⁉️〽️⬅️⬆️⬇️⤴️⤵️©️®️〰️⬛️⬜️🤣🤠🤡🤥🤤🤢🤧🤴🤶🤵🤷🤦🤰🤳🤞🤙🤛🤜🤚🤝🦍🦊🦌🦏🦇🦅🦆🦉🦎🦈🦐🦑🦋🥀🥝🥑🥔🥕🥒🥜🥐🥖🥞🥓🥙🥚🥘🥗🥛🥂🥃🥄🥇🥈🥉🥊🥋🤸🤼🤽🤾🤺🥅🤹🥁‼️©️®️⁉️⤴️⤵️⬆️⬇️⬅️⭐⬛⬜⭕⟹ツღ";
for (int i=0; i<[emoji length]; i++) {
const unichar ch= [emoji characterAtIndex:i];
if ([self characterAtIndex:0] == ch) {
return YES;
break;
}
}
return NO;
}
判断字符串中是否含有表情符号
最新推荐文章于 2025-03-26 19:58:46 发布