• 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: Initializing a string with an NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initializing a string with an NSData


  • Subject: Re: Initializing a string with an NSData
  • From: Aki Inoue <email@hidden>
  • Date: Fri, 29 Jun 2001 17:54:00 -0700

Peter,

Unless you're absolutely sure that your software is never used by
non-English users, it is extremely dangerous to assume default C string
encoding is ASCII. For example, the code might lead to mysterious
crasher problems when executed in Japanese localization.

Aki

On Friday, 6 29, 2001, at 04:53 PM, Peter Ammon wrote:

> on 6/29/01 9:57 AM, Candide Kemmler at email@hidden wrote:
>
>> Hi,
>>
>> The foundation docs states:
>>
>> - (id)initWithData:(NSData *)data
>> encoding:(NSStringEncoding)encoding
>>
>> Problem is: I don't know how to create a valid NSStringEncoding...
>>
>> Sorry for the stupid question, I'm just a beginner. BTW, I'm looking
>> for
>> a good introduction to Objective-C for a non-C programmer (I'm a Java
>> programmer). Don't really know how to handle the * thing (pointers...).
>>
>
> A super easy way to create an NSString from ASCII data stored in an
> NSData
> is
>
> NSString* myString=[NSString stringWithCString:[myData bytes]
> length:[myData
> length]];
>
> -Peter
> _______________________________________________
> cocoa-dev mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Re: Initializing a string with an NSData (From: Peter Ammon <email@hidden>)

  • Prev by Date: Re: NSBezierPath strangeness
  • Next by Date: Is awakeFromNib REALLY first to run?
  • Previous by thread: Re: Initializing a string with an NSData
  • Next by thread: NSBezierPath strangeness
  • Index(es):
    • Date
    • Thread