iPhone: Nsstring has an ó
Hey guys I have an NSString that has an ó inside, so when I put it in a TextView insted of reading "ó" I reads "A³".
So this is what I did:
self._Direccion = [self._Direccion stringByReplacingOccurrencesOfString:@"ó" withString:@"ó"];
but it's not working, I don't know why...
Is working for this:
/* á*/ self._Direccion = [self._Direccion stringByReplacingOccurrencesOfString:@"á" withString:@"á"];
/* é */ self._Direccion = [self._Direccion stringByReplacingOccurrencesOfString:@"é" withString:@"é"];
/* í */ self._Direccion = [self._Direccion stringByReplacingOccurrencesOfString:@"Ã" withString:@"í"];
/* ú */ self._Direccion = [self._Direccion stringByReplacingOccurrencesOfString:@"ú" withString:@"ú"];
but is not working with the "ó" why开发者_如何学C´s that?
Best Regards Carlos Vargas
This is a string encoding issue that you should not fix by manually replacing characters but by building those strings with the right encoding at the very point where you initialize them.
If those strings come from some database with a different encoding than UTF-8 then you can specify that encoding to NSString by using for example:
NSString* string = [NSString stringWithCString: buffer
encoding: NSISOLatin2StringEncoding];
Make sure understand how the source encodes strings first. There are many stringencoding types but the iPhone will support most of them.
精彩评论