OStack程序员社区-中国程序员成长平台

标题: ios - AFNetworking 在多语言应用程序中崩溃 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 01:29
标题: ios - AFNetworking 在多语言应用程序中崩溃

Ride[source_name]=2152,%20Mohali%20Stadium%20Rd,%20Phase%2010,%20Sector%2064,%20Sahibzada%20Ajit%20Singh%20Nagar,%20Punjab%20160062,%20भारत

此参数在以印地语运行时导致崩溃,而在西类牙语和英语下运行良好。请建议我。崩溃描述如下:-

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: URLString'




Best Answer-推荐答案


检查一下

目标 - C

NSString *string = @"भारत";
NSString *encoded = [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];

Swift 3.0

let string = "भारत"
let urlString = string.addingPercentEncoding( withAllowedCharacters: . urlUserAllowed)

Output :: %E0%A4%AD%E0%A4%BE%E0%A4%B0%E0%A4%A4

关于ios - AFNetworking 在多语言应用程序中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44023064/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4