• 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: NUL characters in NSString cause unexpected results
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NUL characters in NSString cause unexpected results


  • Subject: Re: NUL characters in NSString cause unexpected results
  • From: Scott Stevenson <email@hidden>
  • Date: Wed, 22 Nov 2006 20:01:21 -0800


On Nov 22, 2006, at 6:33 PM, Jerry Krinock wrote:

Every reference I can find on UTF8 states that any valid ASCII character is
a valid UTF8 character, so this should include the ASCII 'NUL', 0x0. But
when I init an NSString from data including a NUL, using UTF8 encoding, and
then send some messages to it, most messages behave as though the string
terminates at the NUL.

To be fair, the class reference for NSString is pretty upfront about this:


	-initWithBytes:length:encoding:

Returns an initialized NSString object containing a given number of bytes from
a given C array of bytes in a given encoding.


bytes: A C array of bytes in the encoding specified by encoding. The array
must not contain NULL.


<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ Classes/NSString_Class/Reference/NSString.html>


If some nasty person puts an ASCII 0x0 NUL in the file, it flows right through to my NSString and causes problems
later.

You might need to just preprocess the text.

   - Scott
_______________________________________________

Cocoa-dev mailing list      (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NUL characters in NSString cause unexpected results
      • From: Jerry Krinock <email@hidden>
    • Re: NUL characters in NSString cause unexpected results
      • From: Rosyna <email@hidden>
References: 
 >NUL characters in NSString cause unexpected results (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: NUL characters in NSString cause unexpected results
  • Next by Date: Re: NUL characters in NSString cause unexpected results
  • Previous by thread: Re: NUL characters in NSString cause unexpected results
  • Next by thread: Re: NUL characters in NSString cause unexpected results
  • Index(es):
    • Date
    • Thread