• 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: dumb NSLog question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dumb NSLog question


  • Subject: Re: dumb NSLog question
  • From: Lester Dowling <email@hidden>
  • Date: Mon, 9 Jan 2006 18:55:14 +1100


On 09/01/2006, at 5:15 PM, Kevin Ballard wrote:

Actually that shouldn't be the case at all. You don't want the null byte to be in the NSString itself, so a length of 3 is correct.

No, I think it's more likely that, for whatever reason, NSLog isn't outputting anything unless it has at least one ASCII character, and setting a length of 4 works because the null byte after the (tm) char is enough to make NSLog display the output.

Perhaps you should file a bug on this?

On Jan 8, 2006, at 5:27 PM, Lester Dowling wrote:

'Tis the bletcherous bug of wrong length.

Change the length from 3 to 4:

	NSString *tmChar = [[NSString alloc] initWithBytes:"\xE2\x84\xA2"
			length:4 // Include the terminating null.
			encoding:NSUTF8StringEncoding
		];

Now it works without making hey:

2006-01-09 12:26:21.306 tmlog[537] ™

Yes, you're right. That'll teach me to concentrate properly.

From some quick testing, it seems NSLog is choking when it only has high unicode chars. My original answer of the terminating null made it work for the wrong reason. The following works correctly _and_ for the right reason:

NSString *tmChar = [[NSString alloc] initWithBytes:"\xE2\x84\xA2 " // space char
length:4
encoding:NSUTF8StringEncoding
];
NSLog(tmChar);


gives:

2006-01-09 18:52:22.412 tmlog[989] ™

Sorry about that. I'll take myself out back and shoot myself -- don't worry, I'll do it humanely.

-- Lester

_______________________________________________
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: 
 >dumb NSLog question (From: Matt Neuburg <email@hidden>)
 >Re: dumb NSLog question (From: Lester Dowling <email@hidden>)
 >Re: dumb NSLog question (From: Kevin Ballard <email@hidden>)

  • Prev by Date: Re: Crashing problem on Mac OS X 10.2
  • Next by Date: Creating QTMovie with multiple tracks just for playing them
  • Previous by thread: Re: dumb NSLog question
  • Next by thread: Re: dumb NSLog question
  • Index(es):
    • Date
    • Thread