Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invisible characters in NSTextView



On Mon, 3 Jan 2005 09:17:11 -0600, email@hidden
<email@hidden> wrote:
 
> Unfortunately, the above code doesn't quite work correctly, since
> characterAtIndex: is a character based index, and you are going through
> glyph based indices.  Now while these two are usually the same (and the
> layout manager will insert null-glyphs to help maintain this), there is
> no guarantee that it will be the same, and so you should convert the
> glyph index to character index.
> 

You are correct that it is slightly safer to convert the glyph index
to character index but it is also slightly slower. When I wrote the
code I tested it extensively to see if there I could find a fault with
using the character index instead of the glyph index when testing for
control characters like \t but I could not find any and I still
haven't found any. If you check for other characters you might have a
problem and as Mark points out if it's not plain text you can have
other problems as well. I suppose it's the age old problem of choosing
between slighty safer but slower and sligtly less safe but faster...

Peter
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Invisible characters in NSTextView (From: Jean Bovet <email@hidden>)
 >Re: Invisible characters in NSTextView (From: Peter Borg <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.