Re: Problem with rangeOfString and Umlauts
Re: Problem with rangeOfString and Umlauts
- Subject: Re: Problem with rangeOfString and Umlauts
- From: Gabriel Zachmann via Cocoa-dev <email@hidden>
- Date: Mon, 14 Mar 2022 14:05:06 +0100
>
> It’s hard to tell from the above snippet, but I suspect your strings are
> different in normalization.
I suspected that, too, but I have no expertise in normalization.
> Specifically, I suspect that file_basename uses two Unicode codepoints for
> the ä, and info_item uses only one.
>
> As an experiment, try running both strings through
> -precomposedStringWithCanonicalMapping before doing
Thanks a lot!
That seems to solve the problem.
I have looked up the documentation of the method, but I don't really understand
it.
Could you explain it to me?
To gain more insights (I usually think it's better to understand in depth what
one is doing),
here is some more background info:
One of the strings is derived from a path, like so:
query_ = [[NSMetadataQuery alloc] NSPredicate * predicate = [NSPredicate
predicateWithFormat: @"(kMDItemContentTypeTree = 'public.image')" ];
[query_ setSearchScopes: [NSArray arrayWithObject: mainDirectoryLocation_]];
[query_ setPredicate: predicate];
[query_ startQuery];
.....
NSString * img_filename = [[query_ resultAtIndex: i] valueForAttribute:
@"kMDItemPath"];
file_basename = [[img_filename lastPathComponent]
stringByDeletingPathExtension];
The other string is derived from EXIF data, like so:
CFDictionaryRef tiff_dict;
CFDictionaryGetValueIfPresent( fileProps, kCGImagePropertyTIFFDictionary,
(const void **) & tiff_dict );
CFDictionaryGetValueIfPresent( tiff_dict, kCGImagePropertyTIFFImageDescription,
(const void **) & caption
);
info_item = [[NSString alloc] initWithString: (__bridge NSString *
_Nonnull)(caption)];
Could that explain the funny handling of umlauts I am seeing?
In particular, in the debugger, I can see that the type of file_basename is
actually an (NSPathStore2 *).
Could that be a problem?
Thanks a lot in advance.
Best regards, Gabriel
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden