Skip to content

Commit

Permalink
NSString+RemoveEmoji
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed May 18, 2015
1 parent ea10a4e commit 3d6b500
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Demos/Foundation/NSArray/NSArrayDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ @implementation NSArrayDemoViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSArray *array = @[@"one",@"two",@"three",@"four",@"five",@"six",@"one",@"one",@"one"];
// NSArray *array = @[@"one",@"two",@"three",@"four",@"five",@"six",@"one",@"one",@"one"];

}

Expand Down
16 changes: 8 additions & 8 deletions IOS-Categories.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
A284C14D1AEBD39600D90ED5 /* NSDate+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = A284C14C1AEBD39600D90ED5 /* NSDate+Extension.m */; };
A284C1501AEBD5BB00D90ED5 /* UINavigationController+StackManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A284C14F1AEBD5BB00D90ED5 /* UINavigationController+StackManager.m */; };
A284C1531AEBD6E400D90ED5 /* UIView+Find.m in Sources */ = {isa = PBXBuildFile; fileRef = A284C1521AEBD6E400D90ED5 /* UIView+Find.m */; };
A284C1561AEBD8A400D90ED5 /* NSString+RemoveEmoji.m in Sources */ = {isa = PBXBuildFile; fileRef = A284C1551AEBD8A400D90ED5 /* NSString+RemoveEmoji.m */; };
A284C15B1AEBDAC200D90ED5 /* NSDictionary+JSONString.m in Sources */ = {isa = PBXBuildFile; fileRef = A284C15A1AEBDAC200D90ED5 /* NSDictionary+JSONString.m */; };
A2893D941AC3D42400EFA90A /* UIButton+CountDown.m in Sources */ = {isa = PBXBuildFile; fileRef = A2893D931AC3D42400EFA90A /* UIButton+CountDown.m */; };
A2893D971AC3E5FE00EFA90A /* UIButton+Indicator.m in Sources */ = {isa = PBXBuildFile; fileRef = A2893D961AC3E5FE00EFA90A /* UIButton+Indicator.m */; };
Expand Down Expand Up @@ -173,6 +172,7 @@
A28BE38A1A3ED364005C4AC6 /* UITextView+PlaceHolder.m in Sources */ = {isa = PBXBuildFile; fileRef = A28BE3891A3ED364005C4AC6 /* UITextView+PlaceHolder.m */; };
A28BE38E1A3ED5A4005C4AC6 /* UITextField+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = A28BE38D1A3ED5A4005C4AC6 /* UITextField+Blocks.m */; };
A29266521A78976B00D01EDA /* UIResponder+UIAdapt.m in Sources */ = {isa = PBXBuildFile; fileRef = A29266511A78976B00D01EDA /* UIResponder+UIAdapt.m */; };
A292BDCD1B03422D002DAB71 /* NSString+RemoveEmoji.m in Sources */ = {isa = PBXBuildFile; fileRef = A292BDCC1B03422D002DAB71 /* NSString+RemoveEmoji.m */; };
A2AF02A41A74BACB003FEC8D /* NSDictionary+SafeAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = A2AF02A31A74BACB003FEC8D /* NSDictionary+SafeAccess.m */; };
A2AF02AA1A74C096003FEC8D /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = A2AF02A91A74C096003FEC8D /* NSDictionary+Merge.m */; };
A2C1ADCE1A58F35400E3BAFF /* UIImage+Orientation.m in Sources */ = {isa = PBXBuildFile; fileRef = A2C1ADCD1A58F35400E3BAFF /* UIImage+Orientation.m */; };
Expand Down Expand Up @@ -391,8 +391,6 @@
A284C14F1AEBD5BB00D90ED5 /* UINavigationController+StackManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+StackManager.m"; sourceTree = "<group>"; };
A284C1511AEBD6E400D90ED5 /* UIView+Find.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Find.h"; sourceTree = "<group>"; };
A284C1521AEBD6E400D90ED5 /* UIView+Find.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Find.m"; sourceTree = "<group>"; };
A284C1541AEBD8A400D90ED5 /* NSString+RemoveEmoji.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+RemoveEmoji.h"; sourceTree = "<group>"; };
A284C1551AEBD8A400D90ED5 /* NSString+RemoveEmoji.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+RemoveEmoji.m"; sourceTree = "<group>"; };
A284C1591AEBDAC200D90ED5 /* NSDictionary+JSONString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+JSONString.h"; sourceTree = "<group>"; };
A284C15A1AEBDAC200D90ED5 /* NSDictionary+JSONString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+JSONString.m"; sourceTree = "<group>"; };
A2893D921AC3D42400EFA90A /* UIButton+CountDown.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+CountDown.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -487,6 +485,8 @@
A28BE38D1A3ED5A4005C4AC6 /* UITextField+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextField+Blocks.m"; sourceTree = "<group>"; };
A29266501A78976B00D01EDA /* UIResponder+UIAdapt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIResponder+UIAdapt.h"; sourceTree = "<group>"; };
A29266511A78976B00D01EDA /* UIResponder+UIAdapt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIResponder+UIAdapt.m"; sourceTree = "<group>"; };
A292BDCB1B03422D002DAB71 /* NSString+RemoveEmoji.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+RemoveEmoji.h"; sourceTree = "<group>"; };
A292BDCC1B03422D002DAB71 /* NSString+RemoveEmoji.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+RemoveEmoji.m"; sourceTree = "<group>"; };
A2AF02A21A74BACB003FEC8D /* NSDictionary+SafeAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+SafeAccess.h"; sourceTree = "<group>"; };
A2AF02A31A74BACB003FEC8D /* NSDictionary+SafeAccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+SafeAccess.m"; sourceTree = "<group>"; };
A2AF02A81A74C096003FEC8D /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+Merge.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1256,8 +1256,8 @@
A28BE2DB1A3E9F48005C4AC6 /* NSString */ = {
isa = PBXGroup;
children = (
A284C1541AEBD8A400D90ED5 /* NSString+RemoveEmoji.h */,
A284C1551AEBD8A400D90ED5 /* NSString+RemoveEmoji.m */,
A292BDCB1B03422D002DAB71 /* NSString+RemoveEmoji.h */,
A292BDCC1B03422D002DAB71 /* NSString+RemoveEmoji.m */,
A281FB401AC800F2009040DA /* NSString+Trims.h */,
A281FB411AC800F2009040DA /* NSString+Trims.m */,
A281FB3D1AC80001009040DA /* NSString+Emoji.h */,
Expand Down Expand Up @@ -1754,7 +1754,7 @@
A281FB9E1AC8126F009040DA /* NSFileManagerDemoViewController.m in Sources */,
A281FB3F1AC80001009040DA /* NSString+Emoji.m in Sources */,
A281FB7C1AC811C2009040DA /* BaseViewController.m in Sources */,
A284C1561AEBD8A400D90ED5 /* NSString+RemoveEmoji.m in Sources */,
A292BDCD1B03422D002DAB71 /* NSString+RemoveEmoji.m in Sources */,
A2FD5B4B1A52687000555EA2 /* NSException+Trace.m in Sources */,
A28BE2EC1A3E9F48005C4AC6 /* NSObject+AssociatedObject.m in Sources */,
A24377271ACBF04E00FFFEA1 /* MKMapView+ZoomLevel.m in Sources */,
Expand Down Expand Up @@ -1852,7 +1852,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1887,7 +1887,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
9 changes: 7 additions & 2 deletions IOS-Categories/Foundation/NSString/NSString+RemoveEmoji.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

//https://github.com/woxtu/NSString-RemoveEmoji
//
// NSString+RemoveEmoji.h
// NSString+RemoveEmoji
//
// Created by Jakey on 15/5/13.
// Copyright (c) 2015年 Jakey. All rights reserved.
//
#import <Foundation/Foundation.h>

@interface NSString (RemoveEmoji)
Expand Down
35 changes: 34 additions & 1 deletion IOS-Categories/Foundation/NSString/NSString+RemoveEmoji.m
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
//
// NSString+RemoveEmoji.m
// NSString+RemoveEmoji
//
// Created by Jakey on 15/5/13.
// Copyright (c) 2015年 Jakey. All rights reserved.
//
#import "NSString+RemoveEmoji.h"

@implementation NSString (RemoveEmoji)

- (BOOL)isEmoji {
const unichar high = [self characterAtIndex: 0];

if ([self 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];
Expand All @@ -16,6 +28,27 @@ - (BOOL)isEmoji {
} else {
return (0x2100 <= high && high <= 0x27bf);
}
//
}
-(BOOL)isFuckEmoji{
NSArray *fuckArray =@[@"",@"㊙️",@"㊗️",@"⬅️",@"⬆️",@"⬇️",@"⤴️",@"⤵️",@"#️⃣",@"0️⃣",@"1️⃣",@"2️⃣",@"3️⃣",@"4️⃣",@"5️⃣",@"6️⃣",@"7️⃣",@"8️⃣",@"9️⃣",@"",@"©®",@"〽️",@"‼️",@"⁉️",@"⭕️",@"⬛️",@"⬜️",@"",@"",@"",@"",@"",@"",@"",@"",@"©®",@"",@"",@"",@"",@"",@"",@"",@"©",@"®"];
// NSString *test = @"⭐㊙️㊗️⬅️⬆️⬇️⤴️⤵️#️⃣0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣〰©®〽️‼️⁉️⭕️⬛️⬜️⭕⬆⬇⬅㊙㊗⭕©®⤴⤵〰†⟹ツღ";
// NSMutableArray *array = [NSMutableArray array];
// for (int i = 0;i < [test length]; i++)
// {
// [array addObject:[test substringWithRange:NSMakeRange(i,1)]];
// }
BOOL result = NO;
for(NSString *string in fuckArray){
if ([self isEqualToString:string]) {
return YES;
}
}
if ([@"\u2b50\ufe0f" isEqualToString:self]) {
result = YES;

}
return result;
}

- (BOOL)isIncludingEmoji {
Expand Down

0 comments on commit 3d6b500

Please sign in to comment.