Re: Invisible characters in NSTextView
Re: Invisible characters in NSTextView
- Subject: Re: Invisible characters in NSTextView
- From: Peter Borg <email@hidden>
- Date: Mon, 3 Jan 2005 19:42:11 +0100
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:
This email sent to email@hidden