特定の NSString が NFD 形式であるかどうかを判断する必要があります。それ、どうやったら出来るの?
環境 :
Mac OS から (NSString の形式で) 取得したファイル パスは、正規分解形式 (NFD) です。これは特に、ファイルシステムが HFSPlus の場合に当てはまります。 http://developer.apple.com/mac/library/technotes/tn/tn1150.html#CanonicalDecomposition
これから事前に構成された文字列が必要です。precomposedStringWithCanonicalMapping
ここで、ファイル名が NFD 形式で分解されていることがわかっている場合にのみ、関数を実行したいと考えています。
私が考えることができる解決策:
//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);
}
私の解決策は大丈夫ですか?また、ファイルシステムの出力 (NFD で) についての私の理解は正しいですか?