I'm trying to encode url string using Objective-c
// 1. Get string
char res = ((char)(400));
NSString *unencodedString = [NSString stringWithFormat:@"%c",res];
// 2. Encode string
static NSString *escape = @":/?&=;+!@#$()',*[]";
NSString *result = (__bridge_transfer NSString *)
CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef)unencodedString,
NULL,
(__bridge CFStringRef)escape,
kCFStringEncodingUTF8);
// result = %C2%90
But result is not that I expect. Because I get %C6%90
using other programming languages.
As you see Objective-C result is %C2%90
, but I expect %C6%90
.
Where is my error? Am I do something wrong?