• 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: What encoding to use to turn NSData from a subprocess into an NSString?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What encoding to use to turn NSData from a subprocess into an NSString?


  • Subject: Re: What encoding to use to turn NSData from a subprocess into an NSString?
  • From: "Shawn Erickson" <email@hidden>
  • Date: Tue, 23 May 2006 17:05:17 -0700

On 5/23/06, Gerben Wierda <email@hidden> wrote:
If I have a NSFileHandle that reads from a unix subprocess the stderr
output (this is supposed to be readable output, say the output of a
gnutar command) what encoding do I use to turn the NSData I get with
availableData into an NSString (using initWIthData:encoding)?

The data is ascii, generally, but I cannot be sure there is no 8-bit
value in there. What happens if NSASCIIStringEncoding encounters an 8-
bit value (say an accented character)?

I have been using NSUTF8StringEncoding so far because I read the docs
as that this was an 8 bit encoding. But I have been told that this is
wrong.

As Keary says it is best to know what to expect from the tool(s) you use so you can specify the correct encoding.

With that said using NSUTF8StringEncoding is likely the best choice
since it covers ASCII and since command line tools on Mac OS X are
more likely to return/accept UTF-8 or ASCII then any thing else.

-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >What encoding to use to turn NSData from a subprocess into an NSString? (From: Gerben Wierda <email@hidden>)

  • Prev by Date: Re: What encoding to use to turn NSData from a subprocess into an NSString?
  • Next by Date: Re: NSPredicate and NOT IN and array
  • Previous by thread: Re: What encoding to use to turn NSData from a subprocess into an NSString?
  • Next by thread: Set filePackage
  • Index(es):
    • Date
    • Thread