It seems that NSTask calls -[NSString fileSystemRepresentation] to encode values for each of the arguments you give it.
This can become a problem in some situations due to the fact that -fileSystemRepresentation encodes using decomposed unicode forms: for example, the a-umlaut (ä) would be encoded as U+0061 (Latin small letter a) and U+0308 (Combining diaeresis), as opposed to U+00E4 (Latin small letter a with diaeresis). The -UTF8String method, on the other hand, seems to do the opposite.
I need my NSTask arguments to be encoded using composed forms. How do I work around this issue?
A possible solution would be to subclass
NSStringand provide your own implementation of-fileSystemRepresentation, but unfortunatelyNSStringis a class cluster and thus very difficult to subclass (which is also discouraged by Apple's documentation).However, we can create a separate class that poses as an
NSString, but provides its own implementation of-fileSystemRepresentation.This can, however, create problems if
NSTaskdoes anything with the class identity of the argument objects. Currently I have no evidence that this is the case — this workaround seems to work perfectly.Header:
Implementation: