Is emoji encode UTF16 contain space

83 Views Asked by At

This code determines if a String contains whitespace and newline:

- (BOOL)isNoBlack {
    NSCharacterSet* charSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
    for (int i = 0; i < self.length ; i++) {
        unichar ch = [self characterAtIndex:i];
        NSLog(@"%ld",ch);
        if ([charSet characterIsMember:ch]) {
            return NO;
        }
    }

    return YES;
}

NSString* aStr = @"";

[aStr isNoBlack];

2018-03-01 09:13:05.443731+0800 CustomWindow[1630:110292] 55357
2018-03-01 09:13:05.443864+0800 CustomWindow[1630:110292] 56898

My question is if an Emoji can encode two numbers, one present whitespace or newline, so this method will not work.

0

There are 0 best solutions below