Skip to content

Instantly share code, notes, and snippets.

@sirvon
Created November 22, 2017 18:06
Show Gist options
  • Save sirvon/80edd0c1ac4fb11d8f667feb2fdabee3 to your computer and use it in GitHub Desktop.
Save sirvon/80edd0c1ac4fb11d8f667feb2fdabee3 to your computer and use it in GitHub Desktop.
snipped from FTS4 for HYPERTRACK pod
let view:String.UTF8View = string.utf8
if let from = range.lowerBound.samePosition(in: view),
let to = range.upperBound.samePosition(in: view) {
offset.pointee += Int32(string[string.startIndex..<range.lowerBound].utf8.count)
length.pointee = Int32(view.distance(from: from, to: to))
return token
} else {
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment