• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: finding substring
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding substring


  • Subject: Re: finding substring
  • From: Chuck Soper <email@hidden>
  • Date: Fri, 31 Mar 2006 19:26:00 -0800

Aki,

Thanks for your fast response.

At 5:42 PM -0800 3/31/06, Aki Inoue wrote:
Chuck,

1. Is this a good assumption?
It is not universal. For majority of scripts, accents are essential that stripping them changes the meaning.

This answer makes sense from a programmer's perspective, but from a user's perspective it might be confusing. For example, if someone searches for "San Jose", the results include San Jose, California but not San José, Costa Rica.


My English atlas shows San Jose, California and San José, Costa Rica. I suspect that most users think of the two city names as being the same, but they're not.

Do you think that striping diacritical marks makes sense when comparing some geographical names/languages, but not all, such as localized Japanese names? If so, is there a way to make a distinction?


2. What is the best way to find a sub-string and ignore diacritical marks?
You could strip them by using -[NSString decomposedStringWithCanonicalMapping] and +[NSCharacterSet nonBaseCharacterSet].

I don't understand this suggestion. The following code returns "San José" and I was expecting it to return "San Jose":
NSLog(@"noDiacrit %@", [@"San José" decomposedStringWithCanonicalMapping]);


Could you possibly show a code snippet with the searchStr and placeName variables (used in my code sample)?


I have a plan to add diactric-insensitive flag in a future release.

Aki

Thanks for letting me know.

Chuck



Hello,

I'm assuming that when a user is trying to search for "São Paulo" in my program that they might use "sa" as a search string.

1. Is this a good assumption?
2. What is the best way to find a sub-string and ignore diacritical marks?

I'm currently using this code which does not ignore diacritical marks:
 NSString *searchStr = @"sa";
 NSString *placeName = @"São Paulo";
 NSRange nameRange = [placeName rangeOfString:searchStr
			options:NSCaseInsensitiveSearch];
 if (nameRange.location != NSNotFound)
	NSLog(@"found string!");

Thanks,
Chuck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: finding substring
      • From: Aki Inoue <email@hidden>
    • Re: finding substring
      • From: Daniel Jalkut <email@hidden>
References: 
 >finding substring (From: Chuck Soper <email@hidden>)
 >Re: finding substring (From: Aki Inoue <email@hidden>)

  • Prev by Date: NSArrayController/NSManagedObject Runtime Error: 'Selector Not Recognized'. What Selector?
  • Next by Date: Can't create in-memory paginated PDF based on WebView, but I think I'm close
  • Previous by thread: Re: finding substring
  • Next by thread: Re: finding substring
  • Index(es):
    • Date
    • Thread