Translating filenames for command line?
Translating filenames for command line?
- Subject: Translating filenames for command line?
- From: David Feldman <email@hidden>
- Date: Mon, 31 Dec 2001 11:27:34 -0500
I'm writing a Cocoa app that calls a number of command line tools via
system(). Some of the calls (to ditto, for example) use file paths obtained
from Cocoa (NSDirectoryEnumerator, for example). I'm having trouble with any
path that contains unusual characters, such as bullets or ellipses.
The command line seems to want these characters represented as numerical
equivalents (I'm presuming Unicode or ASCII?). For example, when I get the
shell to auto-complete one of these filenames it represents a bullet as
"\342\200\242" and an ellipsis as "\342\200\246".
However, when these paths are generated by Cocoa the characters are
represented normally. This causes ditto to generate an error, claiming the
file can't be found (and displaying the filename: the ellipses actually
appear there, but the bullets are shown as Yen symbols).
How do I convert Cocoa's characters to the proper numerical equivalents so
the command line tools don't choke?
Thanks,
--Dave