Regarding _PC_NAME_CHARS_MAX, are you saying that the APFS limit is the same as HFS+ (255 UTF-16 encoding units regardless of how many UTF-8 bytes that is)? Or has it been expanded to 255 Swift-style Unicode characters, each of which might be multiple code points?

The explanation for this is going to sound language lawery but this answer is correct for HFS (and for APFS). This applies to the input name you can give to path based system calls and the input encoding for all path based APIs on macOS and iOS on macOS is UTF8.

The answer applies to pathnames that are constructed out the "Portable Filename Character Set" as defined by POSIX ( http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_282 ) which is a subset of ASCII. If you were to construct a pathname out of those characters only, and 255 UTF-16 encoding units for those will take 255 bytes in utf8 and that is the maximum that you can provide as input to the APIs. If you use code points from outside the ASCII range, HFS (and APFS) will aceept greater byte lengths (depending on how many bytes it takes to encode them in utf8. I suspect _PC_NAME_CHARS_MAX is intended to be the reality of 255 unicode "characters"/code points/code units" not matter how many bytes they actually take in utf8 (which is a variable length encoding)

]]>
By: Michael Tsai - Blog - APFS Native Normalization https://mjtsai.com/blog/2017/03/31/apfs-to-add-case-insensitive-variant-for-mac/#comment-2737113
Tue, 27 Jun 2017 18:05:14 +0000https://mjtsai.com/blog/?p=17581#comment-2737113[…] default for macOS 10.13 will be case-insensitive APFS. It is normalization-preserving (unlike HFS+) but not normalization-sensitive. I expect this to be […]
]]>
By: Michael Tsai https://mjtsai.com/blog/2017/03/31/apfs-to-add-case-insensitive-variant-for-mac/#comment-2700800
Fri, 31 Mar 2017 23:04:15 +0000https://mjtsai.com/blog/?p=17581#comment-2700800@Mark Thanks, however I’m not sure I trust that API. HFS+ is supposed to allow 255 UTF-16 encoding units (kHFSPlusMaxFileNameChars) but pathconf(_PC_NAME_MAX) returns 255 for me for both HFS+ and APFS paths. Same with _PC_NAME_CHARS_MAX, although I’m not sure what that is supposed to mean. The man page say that _PC_NAME_MAX is bytes, so 255 is the wrong answer for HFS+.

Also, there doesn’t seem to be a pathconf() equivalent to kHFSMaxVolumeNameChars.

]]>
By: Mark Rowe https://mjtsai.com/blog/2017/03/31/apfs-to-add-case-insensitive-variant-for-mac/#comment-2700782
Fri, 31 Mar 2017 22:30:13 +0000https://mjtsai.com/blog/?p=17581#comment-2700782> It’s also not documented how long APFS filenames can be. It would be nice to have an API for this.

This should be available via pathconf(2) with _PC_PATH_MAX or _PC_NAME_MAX.

A precomposed character (alternatively composite character or decomposable character) is a Unicode entity that can be defined as a sequence of one or more other characters. A precomposed character may typically represent a letter with a diacritical mark, such as é (Latin small letter e with acute accent). Technically, é (U+00E9) is a character that can be decomposed into an equivalent string of the base letter e (U+0065) and combining acute accent (U+0301). Similarly, ligatures are precompositions of their constituent letters or graphemes.

So with the “bag of bytes” you can have two filenames that look like “é” but are made up of different byte sequences. On iOS, if you try to read the file “e followed by acute accent” but it was saved as “Latin small letter e with acute accent”, you will not find the file. With APFS on the Mac, you will. With HFS+, no matter which name you use when saving the file, you’ll get “e followed by acute accent” when you list the directory. With APFS on the Mac, you’ll get the one that you used when creating the file.

]]>
By: Ted Wood https://mjtsai.com/blog/2017/03/31/apfs-to-add-case-insensitive-variant-for-mac/#comment-2700706
Fri, 31 Mar 2017 20:29:51 +0000https://mjtsai.com/blog/?p=17581#comment-2700706For the benefit of those of us that are technically-minded, but not with file-systems, can you provide examples of each scenario?
]]>