• 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: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString initWithData: NSUTF8StringEncoding - returns 'nil'


  • Subject: Re: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
  • From: Douglas Davidson <email@hidden>
  • Date: Fri, 3 Dec 2004 10:04:45 -0800


On Dec 3, 2004, at 9:52 AM, Lance Drake wrote:


I'm reading an RTF file which is contained in a binary file. I need to create an RTF file on the HD - but am having a problem when I try to move the data thru the system.

The following line of code works 'sometimes' with the same data:
NSString* theString = [[NSString alloc] initWithData:strData encoding:NSUTF8StringEncoding];


This line of code always works - with the very same data input:
NSString* theString = [[NSString alloc] initWithData:strData encoding:NSASCIIStringEncoding];


The data is an RTF file which currently does not contain any special UTF8 characters - but could.

The contents of an RTF file may look like a string, but they're not; they should be treated as data. Leave it as an NSData and read and write it using NSData methods.


Douglas Davidson
_______________________________________________
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


  • Follow-Ups:
    • Re: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
      • From: The Karl Adam <email@hidden>
    • Re: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
      • From: Lance Drake <email@hidden>
References: 
 >NSString initWithData: NSUTF8StringEncoding - returns 'nil' (From: Lance Drake <email@hidden>)

  • Prev by Date: Re: NSUserDefaults - When is it written to disk?
  • Next by Date: Re: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
  • Previous by thread: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
  • Next by thread: Re: NSString initWithData: NSUTF8StringEncoding - returns 'nil'
  • Index(es):
    • Date
    • Thread