Re: How to convert a UTF-8 byte offset into an NSString character offset?
Re: How to convert a UTF-8 byte offset into an NSString character offset?
- Subject: Re: How to convert a UTF-8 byte offset into an NSString character offset?
- From: Jens Alfke <email@hidden>
- Date: Tue, 06 May 2014 09:13:29 -0700
On May 5, 2014, at 10:19 PM, Stephen J. Butler <email@hidden> wrote:
> 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.
No, it would probably be to highlight that range of the string in a text view, which does require knowing the character range.
(I can’t say for sure because I’m implementing a library, not an app, so 3rd party apps will be the ultimate users of this information. But since this functionality is about text search, it’s very likely they’d be displaying the hit range to the user.)
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden