I have to POST data to a php page from an Iphone application, so i need to encode the parameters properly, converting the special characters...
Specifically i need to send the UDID of the iphone.
I've found many helps on the web to encode the String to pass as parameter, but i got a strange error.
I'm using this function:
- (NSString *)URLEncodeString:(NSString *)string {
NSString *result =
(NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)string, NULL, CFSTR("'\"?=&+<>;:-"), kCFStringEncodingUTF8);
return [result autorelease];}
it seems correct but when i use it, the result isn't what i expect for.
This is the code:
UIDevice *device = [UIDevice currentDevice];
NSString *uniqueIdentifier = [device uniqueIdentifier];
NSLog(uniqueIdentifier);
NSLog([self URLEncodeString:uniqueIdentifier]);
and this is the Log generated when i hit this code:
2010-06-23 21:58:51.671 provaNavigation[2343:20b] 00000000-0000-1000-8000-0013775CE6D2
2010-06-23 21:58:51.672 provaNavigation[2343:20b] 0000000010003900009080176010001273086780001283520013775CE6D2
and again:
2010-06-23 21:59:25.614 provaNavigation[2343:20b] 00000000-0000-1000-8000-0013775CE6D2
2010-06-23 21:59:25.615 provaNavigation[2343:20b] 000000001000390000908192801000-18000912258750013775CE6D2
and again:
2010-06-23 21:59:40.848 provaNavigation[2343:20b] 00000000-0000-1000-8000-0013775CE6D2
2010-06-23 21:59:40.849 provaNavigation[2343:20b] 000000001000390000908866081000-18000912239630013775CE6D2
and again...
i get a different value every time and never correct with the right %number.
I'm going crazy, somebody can help me? Thanks