   internal func transcoded(withOffset n: Int) -> String.Index {
     _internalInvariant(self.transcodedOffset == 0)
     return String.Index(encodedOffset: self._encodedOffset, transcodedOffset: n)
+  }
+}
+
+extension String.Index {
+  @_alwaysEmitIntoClient @inline(__always) // Swift 5.7
+  internal static var __scalarAlignmentBit: UInt64 { 0x1 }
+
+  @_alwaysEmitIntoClient @inline(__always) // Swift 5.7
+  internal static var __characterAlignmentBit: UInt64 { 0x2 }
+
+  @_alwaysEmitIntoClient @inline(__always) // Swift 5.7
+  internal static var __utf8Bit: UInt64 { 0x4 }
+
+  @_alwaysEmitIntoClient @inline(__always) // Swift 5.7
+  internal static var __utf16Bit: UInt64 { 0x8 }
+
+  @_alwaysEmitIntoClient @inline(__always) // Swift 5.7
+  internal static func __encodingBit(utf16: Bool) -> UInt64 {
+    let utf16 = Int8(Builtin.zext_Int1_Int8(utf16._value))
+    return __utf8Bit &<< utf16
   }
 }
 

  @inline(__always)
  internal var _canBeUTF16: Bool {
    // The only way an index cannot be UTF-16 is it has only the UTF-8 flag set.
    _rawBits & 0xC != 0x04
  }

  /// Returns the same index with the UTF-8 bit set.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var _knownUTF8: Self { Self(_rawBits | 0x4) }

  /// Returns the same index with the UTF-16 bit set.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var _knownUTF16: Self { Self(_rawBits | 0x8) }

  /// Returns the same index with both UTF-8 & UTF-16 bits set.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var _encodingIndependent: Self { Self(_rawBits | 0xC) }

  /// Returns true if the UTF-8 flag is set.
  ///
  /// This is for debugging purposes only. Do not use this property to determine
  /// whether an index is compatible with UTF-8 storage; instead, use
  /// `_canBeUTF8`.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var __isUTF8: Bool { _rawBits & 0x4 != 0 }

  /// Returns true if the UTF-16 flag is set.
  ///
  /// This is for debugging purposes only. Do not use this property to determine
  /// whether an index is compatible with UTF-16 storage; instead, use
  /// `_canBeUTF16`.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var __isUTF16: Bool { _rawBits & 0x8 != 0 }

  @_alwaysEmitIntoClient // Swift 5.7
  internal func _copyEncoding(from index: Self) -> Self {
    Self((_rawBits & ~0xC) | (index._rawBits & 0xC))
  }
}


  @inline(__always)
  internal var _canBeUTF8: Bool {
    // The only way an index cannot be UTF-8 is it has only the UTF-16 flag set.
    _encodingBits != Self.__utf16Bit
  }

  /// Returns true if the position in this index can be interpreted as offset
