• 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: Normalising file names on macOS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Normalising file names on macOS


  • Subject: Re: Normalising file names on macOS
  • From: Clark Cox <email@hidden>
  • Date: Thu, 29 Sep 2016 12:31:57 -0700

> On Sep 22, 2016, at 08:30, Ken Thomases <email@hidden> wrote:
>
> On Sep 22, 2016, at 6:04 AM, John Brownie <email@hidden> wrote:
>>
>> I find that I am in need of dealing with versions of strings that may be turned into file names, and thus I need to be comparing normalised forms.

If you need to compare unicode strings, you don't need to worry about the normalization form (if any) of either string as long as you either normalize them yourself or your a method of comparing them that does canonical comparison (e.g. -compare:).

>> However, according to https://developer.apple.com/library/content/qa/qa1173/_index.html, "For example, HFS Plus (Mac OS Extended) uses a variant of Normal Form D in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through U+2FAFF are not decomposed (this avoids problems with round trip conversions from old Mac text encodings)."
>>
>> Is there a way to get at this variant? [NSString decomposedStringWithCanonicalMapping] returns "A string made by normalizing the string’s contents using the Unicode Normalization Form D." That seems not to give what I need, but I haven't seen a better option. Is there such a method?
>
> Without undermining Alastair's recommendations, you can achieve what you want by round-tripping the string through -[NSString fileSystemRepresentation] and -[NSFileManager stringWithFileSystemRepresentation:length:].  That handles the normalization, but it doesn't do anything about characters that aren't legal in file names on a given file system.

That is not entirely correct, whether or not those methods do normalization varies from one OS version to another, and it is not actually part of the API contract.



_______________________________________________

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


References: 
 >Normalising file names on macOS (From: John Brownie <email@hidden>)
 >Re: Normalising file names on macOS (From: Ken Thomases <email@hidden>)

  • Prev by Date: Multipeer between macOS Sierra and iOS 10
  • Next by Date: Re: URL.setResourceValues() in Swift 3
  • Previous by thread: Re: Normalising file names on macOS
  • Next by thread: Entitlements for non-appstore developer-id signed apps
  • Index(es):
    • Date
    • Thread