Problem with stringByReplacingOccurrencesOfString:withString: and OBJECT REPLACEMENT CHARACTER (U+FFFC)

Originator:stephan.michels
Number:rdar://18423353 Date Originated:23-Sep-2014 09:38 AM
Status:Open Resolved:
Product:OS X SDK Product Version:Mac OS X 10.9.4 (13E28)
Classification:Other Bug Reproducible:Always
 
Summary:
Removing Object Replacement Characters with [NSString stringByReplacingOccurrencesOfString:withString:] doesn’t seems to work reliable.

Steps to Reproduce:
I tried to remove the character by replacing them with an empty string:

	NSString *string = @"Text \ufffc\u20ddC Name";
        NSCAssert(string.length == 13, @"Unexpected string length");
        NSLog(@"BEFORE: \"%@\"", string);
        
        string = [string stringByReplacingOccurrencesOfString:@"\ufffc"
                                                   withString:@""];

        NSLog(@"AFTER: \"%@\"", string);
        NSCAssert(string.length == 12, @"Unexpected string length");

The characters come from the text extraction of the Apple PDF framework.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!