在我的应用程序中,我有一项支持西班牙语并以西班牙语返回结果的服务。现在我正在尝试将一些搜索词传递给该服务以获取结果,但它失败了,因为在发送编译器时将这个词转换为一些带有不明字符的有趣词。我正在这样做:这里的名称是西班牙语,但是当我在配置字典中添加它时,它会再次转换为一些有趣的东西。
-(void)perfromLocationSearchWithName:(NSString *)name{
NSData * nameCode = [[NSData alloc]init];
nameCode = [name dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString * namePass = [[NSString alloc]initWithData:nameCode encoding:NSUTF8StringEncoding];
NSLog(@"Name:%@",namePass);
NSMutableDictionary *config = [[[NSMutableDictionary alloc] initWithCapacity:4] autorelease];
NSString * strAction = [NSString stringWithFormat:@"vendorSearchByName"];
if (namePass !=nil){
[config setObject:namePass forKey:@"vendorName"];
//[config setObject:@"001" forKey:@"MakeCode"];
[config setObject:@"5" forKey:@"maxCount"];
[config setObject:strAction forKey:@"action"];
}
NSLog(@"Dict%@",[config description]);
comm = [[CommManager alloc] init];
[comm searchDealerLocationWithOptions:config withDelegate:self];
[namePass release];
}
请帮忙谢谢,