Latest 1.0.3
Homepage https://github.com/iandai/IDEmojiString
License MIT
Platforms osx , ios , tvos , watchos
Frameworks Foundation
Authors

IDEmojiString is a simple tool to detect emoji in string, and also remove emoji from string.

IDEmojiString detects an emoji by search through full emoji set loaded from emoji.plist. Emoji.plist extracted from http://unicode.org/Public/emoji/4.0/emoji-test.txt, which is the best definition of the full set indicated in http://www.unicode.org/reports/tr51/#Identification.

Purpose

NSString’s existing method - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)searchSet; only supports character set in BMP, not supplementary characters. For example:


NSMutableCharacterSet *set = [[NSMutableCharacterSet alloc] init];
[set addCharactersInString:@"2️⃣"];      // keycap 2, 0032 FE0F 20E3, github seems not supporting this emoji. Check from http://www.iemoji.com/view/emoji/296/symbols/keycap-2 
[@"2" rangeOfCharacterFromSet:set];     // return value: YES, which is not reasonable 

Existing library does not solve emoji perfectly. NSString+RemoveEmoji category, which quoted by many articles, does not detect emoji such as @"⭐", and detects character such as @"Ⅶ" which is not emoji. Test here

Usage

#import "IDEmojiManager.h"

IDEmojiManager *manager = [[IDEmojiManager alloc] init];
BOOL containsEmoji = [manager containEmojiInString:@"Some String⭐"];  // return value: YES
NSString *str = [manager removeEmojiFromString:@"Some String⭐"];      // return value: Some String

Install

Use CocoaPods.

pod 'IDEmojiString'

Communication

If you found a bug, open an issue.

License

IDEmojiString is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "IDEmojiString",
    "version": "1.0.3",
    "summary": "A libarary that detects and removes Emoji.",
    "homepage": "https://github.com/iandai/IDEmojiString",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Ian Dai": "[email protected]"
    },
    "source": {
        "git": "https://github.com/iandai/IDEmojiString.git",
        "tag": "1.0.3"
    },
    "source_files": "IDEmojiString/*{h,m}",
    "exclude_files": "IDEmojiString/main.m",
    "resources": "IDEmojiString/emoji.plist",
    "frameworks": "Foundation",
    "platforms": {
        "osx": null,
        "ios": null,
        "tvos": null,
        "watchos": null
    }
}

Pin It on Pinterest

Share This