Re: [swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-04-06 Thread Tyler Stromberg via swift-dev
> On Mar 24, 2017, at 12:08 PM, Ben Langmuir wrote: > > >> On Mar 24, 2017, at 10:59 AM, Tyler Stromberg via swift-dev >> wrote: >> >> I'm currently working on integrating SourceKit with a macOS application. >> AppKit APIs (e.g. NSAttributedString,

Re: [swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-03-24 Thread Jean-Pierre Simard via swift-dev
I ended up writing some convenience APIs to perform these conversions along with many other useful SourceKit<->Cocoa conversions like line+column, UTF-8, UTF-16 and String.Index in SourceKitten. It's MIT-licensed so feel free to grab the String extensions from the project yourself:

Re: [swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-03-24 Thread Ben Langmuir via swift-dev
> On Mar 24, 2017, at 10:59 AM, Tyler Stromberg via swift-dev > wrote: > > I'm currently working on integrating SourceKit with a macOS application. > AppKit APIs (e.g. NSAttributedString, NSLayoutManager, etc) deal in terms of > NSRange (UTF-16 code units?). SourceKit,

[swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-03-24 Thread Tyler Stromberg via swift-dev
I'm currently working on integrating SourceKit with a macOS application. AppKit APIs (e.g. NSAttributedString, NSLayoutManager, etc) deal in terms of NSRange (UTF-16 code units?). SourceKit, however, deals in terms of integer offsets and lengths (UTF-8 code units?). Is there a more efficient