I'm trying to find out exactly how I can match the first n
characters of a string with another. Here's some code I've got at the moment:
CFStringRef myStringRef = CFSTR("hello");
CFStringRef otherStringRef = CFSTR("helloworld");
CFIndex cmpChars = CFStringGetLength(myStringRef);
CFComparisonResult res = CFStringCompareWithOptions(myStringRef, otherStringRef, CFRangeMake(0, cmpChars), kCFCompareCaseInsensitive);
printf("Res: %i\n", (int)res);
I get the value of res
as -1
, meaning 'less than' according to the documentation. Surely though, since I specified the range to match it should only take that range into account?