Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store and compare file names as suggested in DSStoreFormat.pod #1

Merged
merged 1 commit into from
Jul 7, 2014

Conversation

dliessi
Copy link
Contributor

@dliessi dliessi commented Jul 6, 2014

From http://search.cpan.org/~wiml/Mac-Finder-DSStore/DSStoreFormat.pod:
"My guess is that the string comparison follows the same rules as HFS+
described in Apple's TN1150."
https://developer.apple.com/legacy/library/technotes/tn/tn1150.html
specifies that "Unicode strings will be stored in fully decomposed form,
with composing characters stored in canonical order" and contains a
FastUnicodeCompare routine defined as the "HFS Plus case-insensitive
string comparison algorithm"

The unorm module is used to fully decompose and canonically order
filename strings. The FastUnicodeCompare routine is implemented as
HFSPlusFastUnicodeCompare and used in Entry.sort instead of
localeCompare.

This solves LinusU/node-appdmg#33.

(At first I only added .toLowerCase() to filename strings in Entry.sort,
which solved the issue, but only in case of names containing only latin
letters without diacritics.)

From http://search.cpan.org/~wiml/Mac-Finder-DSStore/DSStoreFormat.pod:
"My guess is that the string comparison follows the same rules as HFS+
described in Apple's TN1150."
https://developer.apple.com/legacy/library/technotes/tn/tn1150.html
specifies that "Unicode strings will be stored in fully decomposed form,
with composing characters stored in canonical order" and contains a
FastUnicodeCompare routine defined as the "HFS Plus case-insensitive
string comparison algorithm"

The unorm module is used to fully decompose and canonically order
filename strings.  The FastUnicodeCompare routine is implemented as
HFSPlusFastUnicodeCompare and used in Entry.sort instead of
localeCompare.

This solves LinusU/node-appdmg#33.

(At first I only added .toLowerCase() to filename strings in Entry.sort,
which solved the issue, but only in case of names containing only latin
letters without diacritics.)
@LinusU LinusU merged commit 3b12adb into LinusU:master Jul 7, 2014
@LinusU
Copy link
Owner

LinusU commented Jul 7, 2014

Did some refactoring on the code but need to run now. If you have time to test the latest master it would be appreciated.

Thanks for the help, it was some solid work!

I'll push to npm as soon as I know that it is working.

@dliessi dliessi deleted the filenames branch July 7, 2014 16:39
@dliessi
Copy link
Contributor Author

dliessi commented Jul 7, 2014

It works in my tests (latin letters with diacritics, cyrillic and armenian letters).

Thanks for the help, it was some solid work!

:)

@LinusU
Copy link
Owner

LinusU commented Jul 7, 2014

Super, thank you! I'll push new versions to npm now :)

Again, thanks for the help, if you ever find yourself in Sweden I'll buy you a beer 🍻

@dliessi
Copy link
Contributor Author

dliessi commented Jul 7, 2014

if you ever find yourself in Sweden I'll buy you a beer 🍻

I'm counting on it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants