Skip to content

Commit bdfc262

Browse files
authored
Rollup merge of #103102 - H4x5:len_utf16_docs, r=scottmcm
Clarify the possible return values of `len_utf16` `char::len_utf16` always return 1 or 2. Clarify this in the docs, in the same way as `char::len_utf8`.
2 parents 2c0bfbe + a637252 commit bdfc262

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/char/methods.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,14 @@ impl char {
597597
/// Returns the number of 16-bit code units this `char` would need if
598598
/// encoded in UTF-16.
599599
///
600+
/// That number of code units is always either 1 or 2, for unicode scalar values in
601+
/// the [basic multilingual plane] or [supplementary planes] respectively.
602+
///
600603
/// See the documentation for [`len_utf8()`] for more explanation of this
601604
/// concept. This function is a mirror, but for UTF-16 instead of UTF-8.
602605
///
606+
/// [basic multilingual plane]: http://www.unicode.org/glossary/#basic_multilingual_plane
607+
/// [supplementary planes]: http://www.unicode.org/glossary/#supplementary_planes
603608
/// [`len_utf8()`]: #method.len_utf8
604609
///
605610
/// # Examples

0 commit comments

Comments
 (0)