WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI = wxGet_wxConvLocalPtr();
#ifdef __DARWIN__
-// The xnu kernel always communicates file paths in decomposed UTF-8.
-// WARNING: Are we sure that CFString's conversion will cause decomposition?
+// It is important to use this conversion object under Darwin as it ensures
+// that Unicode strings are (re)composed correctly even though xnu kernel uses
+// decomposed form internally (at least for the file names).
static wxMBConv_cf wxConvMacUTF8DObj(wxFONTENCODING_UTF8);
#endif
if ( theString == NULL )
return wxCONV_FAILED;
+ // Ensure that the string is in canonical composed form (NFC): this is
+ // important because Darwin uses decomposed form (NFD) for e.g. file
+ // names but we want to use NFC internally.
+ wxCFRef<CFMutableStringRef>
+ cfMutableString(CFStringCreateMutableCopy(NULL, 0, theString));
+ CFStringNormalize(cfMutableString, kCFStringNormalizationFormC);
+ theString = cfMutableString;
+
/* NOTE: The string content includes the NULL element if the source string did
* That means we have to do nothing special because the destination will have
* the NULL element iff the source did and the NULL element will be included