When I store a NSString inside some NSDictionary and log that dictionary to the console like this:
NSString *someString = @\"Münster\";
NSDictionary *som
The problem could be solved using a loop on a UniChar-string representation of the given string. Implemented as extension on NSString it would look something like this:
- (NSString *) escapedUnicode
{
NSMutableString *uniString = [ [ NSMutableString alloc ] init ];
UniChar *uniBuffer = (UniChar *) malloc ( sizeof(UniChar) * [ self length ] );
CFRange stringRange = CFRangeMake ( 0, [ self length ] );
CFStringGetCharacters ( (CFStringRef)self, stringRange, uniBuffer );
for ( int i = 0; i < [ self length ]; i++ ) {
if ( uniBuffer[i] > 0x7e )
[ uniString appendFormat: @"\\u%04x", uniBuffer[i] ];
else
[ uniString appendFormat: @"%c", uniBuffer[i] ];
}
free ( uniBuffer );
NSString *retString = [ NSString stringWithString: uniString ];
[ uniString release ];
return retString;
}