From ad1e90604b48535eabe22ec0af0479094370fa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=8F=91=E5=86=AC?= Date: Sun, 3 Sep 2023 00:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=B9=BF=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ifish.xcodeproj/project.pbxproj | 4 +-- Ifish/Ifish.entitlements | 2 ++ Ifish/airkiss/JMAirKissConnection.m | 39 +++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 1c55af1..9f7c9bc 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -16101,7 +16101,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 10; DEVELOPMENT_TEAM = WFX8GD5HFX; ENABLE_BITCODE = NO; ENABLE_TESTABILITY = YES; @@ -16221,7 +16221,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 10; DEVELOPMENT_TEAM = WFX8GD5HFX; ENABLE_BITCODE = NO; ENABLE_TESTABILITY = YES; diff --git a/Ifish/Ifish.entitlements b/Ifish/Ifish.entitlements index a4896c8..bdbfb61 100644 --- a/Ifish/Ifish.entitlements +++ b/Ifish/Ifish.entitlements @@ -8,5 +8,7 @@ com.apple.external-accessory.wireless-configuration + com.apple.developer.networking.multicast + diff --git a/Ifish/airkiss/JMAirKissConnection.m b/Ifish/airkiss/JMAirKissConnection.m index 73483d3..6e2e044 100644 --- a/Ifish/airkiss/JMAirKissConnection.m +++ b/Ifish/airkiss/JMAirKissConnection.m @@ -77,6 +77,11 @@ */ - (void)connectAirKissWithSSID:(NSString *)ssidStr password:(NSString *)password { + //处理中文的情况 + if([self validateContainsChinese:ssidStr]) + { + ssidStr = [ssidStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + } NSMutableArray *dataArray = [_airKissEncoder createAirKissEncorderWithSSID:ssidStr ? :@"" password:password ? :@""]; @@ -104,11 +109,11 @@ [mData appendBytes:&value length:1]; } NSString*host = kAirKiss_Host; - if (@available(iOS 16.0, *)) - { - NSArray *arr = [_localIP componentsSeparatedByString:@"."]; - host=[NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]]; - } +// if (@available(iOS 16.0, *)) +// { +// NSArray *arr = [_localIP componentsSeparatedByString:@"."]; +// host=[NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]]; +// } [_clientUdpSocket sendData:mData toHost:host @@ -135,6 +140,30 @@ _clientUdpSocket = nil; _serverUdpSocket = nil; } +- (BOOL)validateContainsChinese:(NSString *)content + +{ + + // ^[\u4e00-\u9fa5] 以中文开头 的字符串 + + // [\u4e00-\u9fa5] 包含中文 + + NSRegularExpression *regularexpression = [[NSRegularExpression alloc] + + initWithPattern:@"^[\u4e00-\u9fa5]" + + options:NSRegularExpressionCaseInsensitive + + error:nil]; + + return ([regularexpression numberOfMatchesInString:content + + options:NSMatchingReportProgress + + range:NSMakeRange(0, content.length)] > 0); + +} + #pragma mark - Set up udp socket - (void)setupClientUdpSocket