• 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: Problem with rangeOfString and Umlauts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Problem with rangeOfString and Umlauts
      • From: Aandi Inston via Cocoa-dev <email@hidden>
References: 
 >Problem with rangeOfString and Umlauts (From: Gabriel Zachmann via Cocoa-dev <email@hidden>)
 >Re: Problem with rangeOfString and Umlauts (From: Matt Jacobson via Cocoa-dev <email@hidden>)

  • Prev by Date: Re: NSControl subclass and accessibility
  • Next by Date: Re: Problem with rangeOfString and Umlauts
  • Previous by thread: Re: Problem with rangeOfString and Umlauts
  • Next by thread: Re: Problem with rangeOfString and Umlauts
  • Index(es):
    • Date
    • Thread