Search code examples
iosxcodecocoaapostrophe

my apostrophe turns into ’


i'm trying to send the iOS device name along with the deviceToken to my server in didRegisterForRemoteNotificationsWithDeviceToken.. my device has an apostrophe in it and the request string shows as ....&name=John+Doe’s+iPhone ... I've tried replacing "'" with "" and "’" with "" .. but neither fix it.. i assume i need to convert the encoding?

NSString *string = [[UIDevice currentDevice] name];
output-> John Doe’s iPhone

EDIT

output is from NSLog(string);


Solution

  • You should never use NSLog with a user-provided string like that. NSLog expects a format string for its first argument. If it's something containing a format specifier, it will probably crash your application, and may expose a security hole if provided by an untrusted source.

    Your encoding issue appears to be a bug in LLDB. Switching to GDB fixes the problem.