I am using libxml2 in my iPhone app. I have an NSString that holds the pathname to an XML file. The pathname may include non-ASCII characters. I want to get a C string representation of the NSString for to pass to xmlReadFile(). It appears that cStringUsingEncoding gives me the representation I seek. I am not clear on which encoding to use.
I wonder if there is a “default” encoding in iPhone OS that I can use here and ensure that I can roundtrip non-ASCII pathnames.
Use NSString’s
fileSystemRepresentation. If the string contains characters that are not representable in the file system’s encoding then this method will raise an exception.To convert back, use NSFileManager’s
stringWithFileSystemRepresentation:length: