将数据发布到服务器时出现信件问题
NSString *url = [NSString stringWithFormat:@"http://100.200.30.400/iph/req.php?ph=%@&lat=%@&lon=%@&name=%@&stor=%@",self.phone,self.latitude,self.longtitude,self.name,self.stor];
NSLog(@"url: %@",url);
NSString *url2 ;
url2 = [NSString stringWithUTF8String:[url UTF8String]];
NSLog(@"url2: %@",url2);
NSURL *reqUrl = [[NSURL alloc] initWithString:url2 ];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:reqUrl];
NSError *error;
NSURLResponse *response;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSStringEncoding responseEncoding = NSUTF8StringEncoding;
if ([response textEncodingName]) {
CFStringEncoding cfStringEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)[response textEncodingName]);
if (cfStringEncoding != kCFStringEncodingInvalidId) {
responseEncoding = CFStringConvertEncodingToNSStringEncoding(cfStringEncoding);
}
}
[reqUrl release];
NSString *dataString = [[NSString alloc] initWithData:data encoding:responseEncoding];
//NSLog(@"dataString: %@",dataString);
if ([dataString intValue] > 0 )
{
NSLog(@"EVERETHING IS GOOD");
}
所以当 self.name 是英文时它工作正常但是当我尝试使用俄语符号时它不起作用。我在浏览器中用俄语符号尝试过,效果很好,这就是问题出在俄语符号中的原因。我必须做什么才能使应用程序与俄罗斯符号一起使用?谢谢