• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to convert a UTF-8 byte offset into an NSString character offset?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to convert a UTF-8 byte offset into an NSString character offset?
      • From: Mark Munz <email@hidden>
References: 
 >How to convert a UTF-8 byte offset into an NSString character offset? (From: Jens Alfke <email@hidden>)
 >Re: How to convert a UTF-8 byte offset into an NSString character offset? (From: "Stephen J. Butler" <email@hidden>)

  • Prev by Date: Re: How to convert a UTF-8 byte offset into an NSString character offset?
  • Next by Date: Re: Creating selector for nonexistent method
  • Previous by thread: Re: How to convert a UTF-8 byte offset into an NSString character offset?
  • Next by thread: Re: How to convert a UTF-8 byte offset into an NSString character offset?
  • Index(es):
    • Date
    • Thread