   ) -> Range<Index>? {
     return _optionalRange(
       _ns.rangeOfCharacter(
-        from: aSet, options: mask,
-        range: _toNSRange(aRange ?? self.characters.indices)))
+        from: aSet,
+        options: mask,
+        range: _toNSRange(
+          aRange ?? self.characters.startIndex..<self.characters.endIndex
+        )
+      )
+    )
   }
 
   // - (NSRange)rangeOfComposedCharacterSequenceAtIndex:(NSUInteger)anIndex

    // dispatching to the minimal selector for the supplied options.
    // So let's do that; the switch should compile away anyhow.
    return locale != nil ? _ns.compare(
      aString, options: mask,
      range: _toNSRange(range ?? self.characters.indices),
      locale: locale)

    : range != nil ? _ns.compare(
      aString,
      options: mask,
      range: _toNSRange(range ?? self.characters.indices))

    : !mask.isEmpty ? _ns.compare(aString, options: mask)


      of: target,
      with: replacement,
      options: options,
      range: _toNSRange(
        searchRange ?? self.characters.startIndex..<self.characters.endIndex
      )
    )
    : _ns.replacingOccurrences(of: target, with: replacement)
  }
