• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Carbon] Using Speech in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Carbon] Using Speech in Cocoa


  • Subject: Re: [Carbon] Using Speech in Cocoa
  • From: Ali Ozer <email@hidden>
  • Date: Mon, 1 Oct 2001 10:09:07 -0700

>> The easiest way to get a Pascal string from an NSString is to use the
>> CoreFoundation function CFStringGetPascalStringPtr().
>
> I'd add
> SpeakString(CFStringGetPascalStringPtr((CFStringRef)AlarmText,CFStringGetSystemEncoding(
> )));
>
> Thanks a lot, I get it now. (I'm not speaking about Pascal)

As Brian Webster pointed out, you should be sure to check for NULL
returns from CFStringGetPascalStringPtr(). This function will return
NULL if it can't return the result immediately; so, if it fails, you
should try to call CFStringGetPascalString(), which might do some
conversion work. If you are not in a performance critical area, you can
just call CFStringGetPascalString() all the time. Or, write a wrapper
which takes a temporary buffer (which the caller should allocate on the
stack), and tries both.

Note that CFStringGetPascalString() might also return NULL if the
conversion can't be done to the specied encoding... At that point
though you're done, unless you want to try other encodings.

The warnings on top of CFString.h are quite useful.

Ali


  • Follow-Ups:
    • Re: [Carbon] Using Speech in Cocoa
      • From: Douglas Davidson <email@hidden>
    • Re: [Carbon] Using Speech in Cocoa
      • From: Andreas Monitzer <email@hidden>
References: 
 >Re: [Carbon] Using Speech in Cocoa (From: Cyril Godefroy <email@hidden>)

  • Prev by Date: Re: NSScrollView and general IB annoyance
  • Next by Date: Re: __MyCompanyName__
  • Previous by thread: Re: [Carbon] Using Speech in Cocoa
  • Next by thread: Re: [Carbon] Using Speech in Cocoa
  • Index(es):
    • Date
    • Thread