larView.Index(utf16Index, within: cafe.unicodeScalars)!

print(String(cafe.unicodeScalars.prefix(upTo: scalarIndex)))
// Prints &quot;Caf√©&quot;</code></pre>

<p>If the position passed in <code>utf16Index</code> doesn&#39;t have an exact
corresponding position in <code>unicodeScalars</code>, the result of the
initializer is <code>nil</code>. For example, an attempt to convert the position of
the trailing surrogate of a UTF-16 surrogate pair fails.</p>

<p><strong>Parameters:</strong>
  <strong>utf16Inde