rangeOfString for quote character works in Mac OSX, not in IOS

rangeOfString for quote character works in Mac OSX, not in IOS.


Here is the code:


        if ([itemRecord.name rangeOfString:itemFilter.nameIncludes options:NSCaseInsensitiveSearch].location == NSNotFound) {
            filterMatch = NO;
        }

itemFilter.nameIncludes in this case is " (the quote character) or it contains the quote character; i.e. 8"

itemRecord.name in this case is Cedar planks 8" x 1"


On Mac OS X this works fine and matches. On iOS 11.4.1, this fails. This seems like a bug in iOS.


Does anyone have a workaround?

Thanks

Replies

try: stringByReplacingOccurancesOfString:@"\"" withString:@"Quote mark"

on both itemRecord.name and itemFilter.nameIncludes

Are you sure that itemFilter.nameIncludes contains a straight/dumb quote (")? I suspect something has automatically made it a smart quote (”).

Yes, the same code is executing against the same values in both OS X and iOS. Must be a bug in iOS.

Yes, that would probably work; however, the code is being run against thousands of records and I don't want to slow the process down. If I don't find nother approach,I'll try this.

Thanks

Why not suspect that iOS is converting the quote mark but MacOS is not? And if you have to do the conversion on thousands of strings it might take .01 seconds.

To be clear, I would only suspect that the quote is being "smartened" if it comes from the user via the UI. I figured his "against the same values" meant it was coming from a database or the like. That shouldn't be converted by the system.

I think you have correctly identified the problem and my 'work around' will not work since it is not coming from a bug but from a feature.