"\U0639\U0646\U0645\U0661\U0662\U0663"
。我尝试了以下一段对我不起作用的代码:
NSString *resourceparams = [NSString stringWithFormat:@"%@",sender,nil];
NSLog(@"before replace resourceparams: %@", resourceparams);
resourceparams = [resourceparams stringByReplacingOccurrencesOfString:@"\\U" withString:@"\\u"];
NSLog(@"after replace resourceparams: %@", resourceparams);
有什么建议吗?
编辑:(添加在Post请求正文中发送此数据的方式)
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
NSEnumerator * enumerator = [[paramDict allKeys] objectEnumerator];
NSString * dataKey = nil;
while (( dataKey = [enumerator nextObject]) ) {
id dataVal = [paramDict objectForKey: dataKey];
[postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundry] dataUsingEncoding:NSUTF8StringEncoding]];
if([dataVal isKindOfClass: [NSData class]]) {
NSString* contentDisposition = [NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"file.ext\"\r\n", dataKey];
[postBody appendData: [contentDisposition dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:dataVal];
} else {
[postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", dataKey] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[dataVal dataUsingEncoding:NSUTF8StringEncoding]];
}
答案 0 :(得分:0)
您可以尝试使用小写的stringobject。您的功能将如下所示:
NSString *resourceparams = [[NSString stringWithFormat:@"%@",sender,nil] lowerCaseString];
这将使每个nsstring对象不大写。