On 06 May 2014, at 20:12, Quincey Morris <quinceymor...@rivergatesoftware.com> 
wrote:
> FWIW, my opinion is that if your library clients are specifying UTF-8 
> sequences at the API, and expect byte offsets into those sequences to be 
> meaningful, you might well be forced to maintain the original UTF-8 sequence 
> in the library’s internal data model — or, perhaps, an array of the original 
> code points — and do all of your internal processing in terms of code points. 
> Conversion to NSString would happen only in the journey from data model to UI 
> text field.

 This is pretty much what I do in one of my projects. I hand-wrote code for 
converting between offsets, mostly based on tutorials from the net, knowing my 
offsets are always at the start/end of code points, and knowing that my 
conversion code always generates the same sequence, just encoding as UTF8/UTF16 
as needed to display in the UI or convert selection offsets back to UTF8 
offsets. The code hasn't shipped (or been tested much beyond myself using the 
app for a while), but if you're interested, contact me off-list and I'll send 
you a copy.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to