Fossil SCM
In utf8.c, explain Unicode case folding on macOS from Apple's official documentation.
Commit
6b3e4f8fbd38377c336694d40806a213c785a6c6cc893360de151cd12d209637
Parent
dc3dbcdca88b811…
1 file changed
+11
-1
+11
-1
| --- src/utf8.c | ||
| +++ src/utf8.c | ||
| @@ -140,11 +140,21 @@ | ||
| 140 | 140 | #elif defined(__CYGWIN__) |
| 141 | 141 | char *zOut; |
| 142 | 142 | zOut = fossil_strdup(zPath); |
| 143 | 143 | return zOut; |
| 144 | 144 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 145 | - char *zIn = (char*)zPath; | |
| 145 | + /* macOS gives us a pathname already in Apple's decomposed form. HFS+ | |
| 146 | + ** stores names "fully decomposed and in canonical order" as per Unicode | |
| 147 | + ** 3.2, while APFS uses the same decomposed form but compares names | |
| 148 | + ** normalization-insensitively as per Unicode 9.0 basis (see Apple TN1150, | |
| 149 | + ** "Unicode Subtleties"; Apple File System Guide FAQ). iconv from | |
| 150 | + ** UTF-8-MAC recomposes the sequence to precomposed UTF-8. So this is a | |
| 151 | + ** composition pass, not full NFC. This function relies on the marks being | |
| 152 | + ** in canonical order as per a real macOS pathname, and it doesn't touch | |
| 153 | + ** characters Apple does not decompose, such as the U+F900-U+FAFF CJK | |
| 154 | + ** compatibility ideographs, again as per Apple documentation. */ | |
| 155 | + char *zIn = (char*)zPath; | |
| 146 | 156 | char *zOut; |
| 147 | 157 | iconv_t cd; |
| 148 | 158 | size_t n, x; |
| 149 | 159 | for(n=0; zIn[n]>0 && zIn[n]<=0x7f; n++){} |
| 150 | 160 | if( zIn[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ |
| 151 | 161 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -140,11 +140,21 @@ | |
| 140 | #elif defined(__CYGWIN__) |
| 141 | char *zOut; |
| 142 | zOut = fossil_strdup(zPath); |
| 143 | return zOut; |
| 144 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 145 | char *zIn = (char*)zPath; |
| 146 | char *zOut; |
| 147 | iconv_t cd; |
| 148 | size_t n, x; |
| 149 | for(n=0; zIn[n]>0 && zIn[n]<=0x7f; n++){} |
| 150 | if( zIn[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ |
| 151 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -140,11 +140,21 @@ | |
| 140 | #elif defined(__CYGWIN__) |
| 141 | char *zOut; |
| 142 | zOut = fossil_strdup(zPath); |
| 143 | return zOut; |
| 144 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 145 | /* macOS gives us a pathname already in Apple's decomposed form. HFS+ |
| 146 | ** stores names "fully decomposed and in canonical order" as per Unicode |
| 147 | ** 3.2, while APFS uses the same decomposed form but compares names |
| 148 | ** normalization-insensitively as per Unicode 9.0 basis (see Apple TN1150, |
| 149 | ** "Unicode Subtleties"; Apple File System Guide FAQ). iconv from |
| 150 | ** UTF-8-MAC recomposes the sequence to precomposed UTF-8. So this is a |
| 151 | ** composition pass, not full NFC. This function relies on the marks being |
| 152 | ** in canonical order as per a real macOS pathname, and it doesn't touch |
| 153 | ** characters Apple does not decompose, such as the U+F900-U+FAFF CJK |
| 154 | ** compatibility ideographs, again as per Apple documentation. */ |
| 155 | char *zIn = (char*)zPath; |
| 156 | char *zOut; |
| 157 | iconv_t cd; |
| 158 | size_t n, x; |
| 159 | for(n=0; zIn[n]>0 && zIn[n]<=0x7f; n++){} |
| 160 | if( zIn[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ |
| 161 |