         self.formIndex(after: &j)
       }
       let end = j
-      try body(current, self[start ..< end])
+      try body(current, self[start ..< end], offset)
+      offset += 1
     }
   }
 }

          if #available(SwiftStdlib 5.7, *) {
            let substring = string[i ..< j]
            expectEqual(
              substring.index(substring.startIndex, offsetBy: characterDistance),
              substring.endIndex,
              """
              string:   \(string.debugDescription)

}

let simpleStrings: [String] = [
  SimpleString.smallASCII.rawValue,
  SimpleString.smallUnicode.rawValue,
  SimpleString.largeASCII.rawValue,
  SimpleString.largeUnicode.rawValue,
  SimpleString.emoji.rawValue,
  "",
]

func dumpIndices(_ string: String) {
  print("-------------------------------------------------------------------")
  print("String: \(String(reflecting: string))")
  print("Characters:")
  string.indices.forEach { i in
    let char = string[i]
    print("  \(i) -> \(String(reflecting: char))")
  }
  print("Unicode Scalars:")
  string.unicodeScalars.indices.forEach { i in
    let scalar = string.unicodeScalars[i]
    let value = String(scalar.value, radix: 16, uppercase: true)
    let padding = String(repeating: "0", count: max(0, 4 - value.count))
    let name = scalar.properties.name ?? "\(scalar.debugDescription)"
    print("  \(i) -> U+\(padding)\(value) \(name)")
  }
  print("UTF-8:")
  string.utf8.indices.forEach { i in
    let code = string.utf8[i]
    let value = String(code, radix: 16, uppercase: true)
    let padding = value.count < 2 ? "0" : ""
    print("  \(i) -> \(padding)\(value)")
  }
  print("UTF-16:")
  string.utf16.indices.forEach { i in
    let code = string.utf16[i]
    let value = String(code, radix: 16, uppercase: true)
    let padding = String(repeating: "0", count: 4 - value.count)
    print("  \(i) -> \(padding)\(value)")
  }
}

StringIndexTests.test("basic sanity checks") {
