Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
update pods
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Mar 18, 2019
1 parent 4e153f4 commit 1da2265
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Manifest.lock
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ CHECKOUT OPTIONS:
:commit: 9599b1d9796280c97cb2f786f34984fc98a3b6ef
:git: https://github.com/signalapp/Mantle
SignalCoreKit:
:commit: 061f41321675ffe5af5e547d578bbd2266a46d33
:commit: 0326310d32744902539bd6a2f170ee7413805754
:git: https://github.com/signalapp/SignalCoreKit.git
SignalMetadataKit:
:commit: 56f28fc3a6e35d548d034ef7d0009f233ca0aa62
Expand Down
3 changes: 3 additions & 0 deletions SignalCoreKit/SignalCoreKit/src/NSString+OWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ NS_ASSUME_NONNULL_BEGIN

- (NSString *)digitsOnly;

@property (nonatomic, readonly) BOOL hasAnyASCII;
@property (nonatomic, readonly) BOOL isOnlyASCII;

- (NSString *)filterStringForDisplay;

- (NSString *)filterFilename;
Expand Down
51 changes: 51 additions & 0 deletions SignalCoreKit/SignalCoreKit/src/NSString+OWS.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,57 @@ - (BOOL)computeHasExcessiveDiacriticals
return NO;
}

+ (NSRegularExpression *)anyASCIIRegex
{
static dispatch_once_t onceToken;
static NSRegularExpression *regex;
dispatch_once(&onceToken, ^{
NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"[\x00-\x7F]+"
options:0
error:&error];
if (error || !regex) {
// crash! it's not clear how to proceed safely, and this regex should never fail.
OWSFail(@"could not compile regex: %@", error);
}
});

return regex;
}

+ (NSRegularExpression *)onlyASCIIRegex
{
static dispatch_once_t onceToken;
static NSRegularExpression *regex;
dispatch_once(&onceToken, ^{
NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"^[\x00-\x7F]*$"
options:0
error:&error];
if (error || !regex) {
// crash! it's not clear how to proceed safely, and this regex should never fail.
OWSFail(@"could not compile regex: %@", error);
}
});

return regex;
}


- (BOOL)isOnlyASCII;
{
return [self.class.onlyASCIIRegex rangeOfFirstMatchInString:self
options:0
range:NSMakeRange(0, self.length)].location != NSNotFound;
}

- (BOOL)hasAnyASCII
{
return [self.class.anyASCIIRegex rangeOfFirstMatchInString:self
options:0
range:NSMakeRange(0, self.length)].location != NSNotFound;
}

- (BOOL)isValidE164
{
NSError *error = nil;
Expand Down

0 comments on commit 1da2265

Please sign in to comment.