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: Mark Munz <email@hidden>
- Date: Tue, 06 May 2014 10:52:45 -0700
> No, it would probably be to highlight that range of the string in a text
view, which does require knowing the character range.
Maybe you could take each of the ranges returned and create a string from
the UTF8 byte stream; search for it in the original string; the results
giving you the range for that string.
Another option could be to rebuild the string from the UTF8 string, noting
the ranges (in the new NSString).
On Tue, May 6, 2014 at 9:13 AM, Jens Alfke <email@hidden> wrote:
>
> 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
>
--
Mark Munz
unmarked software
http://www.unmarked.com/
_______________________________________________
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