Ashutosh
Ashutosh

Reputation: 5742

How to handle Spanish character in my App?

In my app i have a service which supports spanish and return the result in spanish. Now i am trying to pass some search term to this service to get the result back but its failing because while sending compiler converts the word to some funny word with unidentified characters. I am doing this: name here is coming in spanish but when i am adding this in the config dictionary it gets converted again to some funny thing.

-(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];
}

Please help Thanks,

Upvotes: 0

Views: 228

Answers (1)

Hetal Vora
Hetal Vora

Reputation: 3361

Try using NSISOLatin1StringEncoding. Helped us in our app.

Upvotes: 1

Related Questions