Re: How to convert a UTF-8 byte offset into an NSString character offset?

2014-05-05 Thread Stephen J. Butler
What's your next step after doing the UTF8 to UTF16 range conversion? If it's just going to be -[NSString substringWithRange:] then I'd strongly suggest just doing -[NSString initWithBytes:length:encoding:] on the UTF8 string. At least profile it and see what the penalty is. You've already paid the

Re: NSBrowser tooltips

2014-05-05 Thread Ken Thomases
On May 5, 2014, at 4:58 PM, Paul Wasmund wrote: > I am using an NSBrowser to display items and my code is based on the > ComplexBrowser sample from Apple. This uses browser features introduced in > 10.6 and does not implement a NSMatrix to display columns. The only support I > see for implement

NSBrowser tooltips

2014-05-05 Thread Paul Wasmund
I am using an NSBrowser to display items and my code is based on the ComplexBrowser sample from Apple. This uses browser features introduced in 10.6 and does not implement a NSMatrix to display columns. The only support I see for implementing tooltips is browser:shouldShowCellExpansionForRow:col

Re: How to convert a UTF-8 byte offset into an NSString character offset?

2014-05-05 Thread Charles Srstka
On May 5, 2014, at 2:06 PM, Jens Alfke wrote: > How can I map a byte offset in a UTF-8 string back to the corresponding > character offset in the NSString it came from? > > I’m writing an Objective-C wrapper around a C text-tokenizer API that takes a > UTF-8 string as input, and as part of its

How to convert a UTF-8 byte offset into an NSString character offset?

2014-05-05 Thread Jens Alfke
How can I map a byte offset in a UTF-8 string back to the corresponding character offset in the NSString it came from? I’m writing an Objective-C wrapper around a C text-tokenizer API that takes a UTF-8 string as input, and as part of its output returns byte ranges of words that it found. So my

Re: Differences in string handling for NSString and NSAttributedString

2014-05-05 Thread Uli Kusterer
On 05 May 2014, at 18:50, Pax <45rpmli...@googlemail.com> wrote: > Oh bloody hell. I must be tired. That's so obvious - and I'm desperately > embarrassed for not taking care of this. Don't look in the archives, I've asked stupider questions :-) Cheers, -- Uli Kusterer "The Witnesses of TeachTe

Re: Differences in string handling for NSString and NSAttributedString

2014-05-05 Thread Uli Kusterer
To add an example: Original\nString\nGoes\nHere ^8 ^15 ^20 ^25 Now I insert the first image, say just 1 character: Original\nAString\nGoes\nHere ^8 ^16 ^21 ^26 See how all the insertion offsets would have to change? But since you already have your list of ins

Re: Differences in string handling for NSString and NSAttributedString

2014-05-05 Thread Markus Spoettl
On 5/5/14, 6:27 PM, Pax wrote: I believe that this should cause "IMAGE HERE" to be inserted at specific line endings. However, it often inserts into the middle of a paragraph instead - usually, but not always, close to where it should put the text. Furthermore, the positioning is usually at, or

Re: Differences in string handling for NSString and NSAttributedString

2014-05-05 Thread Pax
Oh bloody hell. I must be tired. That's so obvious - and I'm desperately embarrassed for not taking care of this. Thank you so much. On 5 May 2014, at 17:47, Uli Kusterer wrote: > > On 05 May 2014, at 18:27, Pax <45rpmli...@googlemail.com> wrote: >> When I use this with a plain string it a

Differences in string handling for NSString and NSAttributedString

2014-05-05 Thread Pax
I have a an NSAttributedString into which I would like to insert images. The images need to be inserted after specific line endings (I know which line endings in advance - they've been previously calculated). I have written a function which returns an array of all line ending locations (or any