Hi,
i need to determine if a given NSString is in NFD form. how do i do that ?
Context :
the file path i get from mac OS (in form of NSString) is in canonical decomposed form ( NFD ) .. this is true especially when the filesystem is HFSPlus. http://developer.apple.com/mac/library/technotes/tn/tn1150.html#CanonicalDecomposition
i need a precomposed string out of this ...
Now, i want to run the precomposedStringWithCanonicalMapping function only if i know that the filename is decomposed in NFD form.
Solution that i could think of -
//works on the idea that NFD(NFD(x)) = NFD(x)
BOOL IsCanonicallyDecompsed(NSString *initialFilePath)
{
//decompose the string to NFD form -
NSString *nfdFormOfStr = [initialFilePath decomposedStringWithCanonicalMapping];
char *ndfFormUTF8 = [nfdFormOfStr UTF8String];
char *intialPathUTF8 = [initialFilePath UTF8String];
return (strcmp(ndfFormUTF8, intialPathUTF8) == 0);
}
Is my solution OK ? also, is my understanding about the filesystem output ( in NFD ) correct ?
thanks