• 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: Ondra Cada <email@hidden>
  • Date: Sat, 1 Apr 2006 04:05:31 +0200

Aki,

On 1.4.2006, at 3:42, Aki Inoue wrote:

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

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].

Alternatively, predicates *should* help, should they not?

Anyway they don't -- do I overlook something, or is that a known bug?

#import <Cocoa/Cocoa.h>
static inline void pp(NSPredicate *p,NSString *s) {
NSLog(@"string (%@) predicate (%@) -> %d",s,p,[p evaluateWithObject:s]);
}
int main() {
[NSAutoreleasePool new];
id p=[NSPredicate predicateWithFormat:@"SELF contains[cd] 's'"];
pp(p,@"x");
pp(p,@"s");
pp(p,@"S");
pp(p,[NSString stringWithFormat:@"%C",0x1e67]); // s caron
pp(p,[NSString stringWithFormat:@"%C",0x1e66]); // S caron
return 0;
}


prints out

161 /tmp> cc -Wall q.m -framework Cocoa && ./a.out
2006-03-15 22:20:25.893 a.out[1301] string (x) predicate ("s" IN[cd] SELF) -> 0
2006-03-15 22:20:25.897 a.out[1301] string (s) predicate ("s" IN[cd] SELF) -> 1
2006-03-15 22:20:25.900 a.out[1301] string (S) predicate ("s" IN[cd] SELF) -> 1
2006-03-15 22:20:25.911 a.out[1301] string (ṧ) predicate ("s" IN[cd] SELF) -> 0
2006-03-15 22:20:25.911 a.out[1301] string (Ṧ) predicate ("s" IN[cd] SELF) -> 0
162 /tmp>


---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc


_______________________________________________ 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
References: 
 >finding substring (From: Chuck Soper <email@hidden>)
 >Re: finding substring (From: Aki Inoue <email@hidden>)

  • Prev by Date: Re: finding substring
  • Next by Date: NSArrayController/NSManagedObject Runtime Error: 'Selector Not Recognized'. What Selector?
  • Previous by thread: Re: finding substring
  • Next by thread: Re: finding substring
  • Index(es):
    • Date
    • Thread