• 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: Gregory Weston <email@hidden>
  • Date: Mon, 9 Jan 2006 07:07:21 -0500

Lester Dowling wrote:

On 09/01/2006, at 12:10 PM, Matt Neuburg wrote:

Why doesn't this code work?

NSString* tmChar = [[NSString alloc] initWithBytes:"\xE2\x84\xA2"
    length:3 encoding:NSUTF8StringEncoding];
NSLog(@"%@",tmChar);

...

'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] ™

That may fix it, but it doesn't seem like it should especially given that it's documented that none of the bytes are to be NULL and that the first argument is void* so there's no guarantee the caller will be using a string. There's no change in behavior, for example, if you make the first argument reference this:
char foo[3] = {0xe2,0x84,0xa2};


Feels like a bug in NSLog, and seems to be addressed without actually affecting the output by throwing a \n onto the end of the format string. _______________________________________________
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
  • Prev by Date: How to write predicate to filter for to-many relationship
  • Next by Date: Managing selectedObjects
  • Previous by thread: Re: dumb NSLog question
  • Next by thread: Radix Class
  • Index(es):
    • Date
    • Thread