Skip navigation.
 
mlRe: Write text to the stdout
FROM : Marcel Weiher
DATE : Fri Jan 03 15:31:20 2003

On Friday, January 3, 2003, at 02:57  Uhr, Arthur VIGAN wrote:

> I am programming a Foundation Tool for use with the terminal app, but
> I have troubles to ouput text in the terminal (the stdout in this
> case). The problem comes with the NSString. I can't use the printf()
> function with NSString, so what should I use?


   printf( "%s",[myString cString]);

or maybe lossyCString, as cString will raise an exception if some of
the characters aren't representable in the default cstring encoding
(usually MacOSRoman).

You can also use MPWFoundation's  MPWByteStream class, which for an
isolated case would look like this:

   [[MPWByteStream Stdout] writeObject:myString];

or

   [outStream writeObject:myString];

if you have already gotten the Stdout stream earlier.  The clue about
-writeObject: is that it will take any object whatsoever and print it
(to an arbitrary stream).  The default behavior is to print the
-description, but objects can easily override that behavior.

Marcel

--
Marcel Weiher                Metaobject Software Technologies
<email_removed>        www.metaobject.com
Metaprogramming for the Graphic Arts.  HOM, IDEAs, MetaAd etc.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlWrite text to the stdout Arthur VIGAN Jan 3, 14:57
mlRe: Write text to the stdout Yann Bizeul Jan 3, 15:15
mlRe: Write text to the stdout Finlay Dobbie Jan 3, 15:21
mlRe: Write text to the stdout Arthur VIGAN Jan 3, 15:29
mlRe: Write text to the stdout Marcel Weiher Jan 3, 15:31