Skip to content

Commit 0da9358

Browse files
hkBstgitbot
authored and
gitbot
committedMar 6, 2025
Update encode_utf16 to mention it is native endian
1 parent 91fd9ce commit 0da9358

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed
 

‎alloc/src/string.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ impl String {
712712
}
713713
}
714714

715-
/// Decode a UTF-16–encoded vector `v` into a `String`, returning [`Err`]
716-
/// if `v` contains any invalid data.
715+
/// Decode a native endian UTF-16–encoded vector `v` into a `String`,
716+
/// returning [`Err`] if `v` contains any invalid data.
717717
///
718718
/// # Examples
719719
///
@@ -745,8 +745,8 @@ impl String {
745745
Ok(ret)
746746
}
747747

748-
/// Decode a UTF-16–encoded slice `v` into a `String`, replacing
749-
/// invalid data with [the replacement character (`U+FFFD`)][U+FFFD].
748+
/// Decode a native endian UTF-16–encoded slice `v` into a `String`,
749+
/// replacing invalid data with [the replacement character (`U+FFFD`)][U+FFFD].
750750
///
751751
/// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`],
752752
/// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
@@ -777,8 +777,8 @@ impl String {
777777
.collect()
778778
}
779779

780-
/// Decode a UTF-16LE–encoded vector `v` into a `String`, returning [`Err`]
781-
/// if `v` contains any invalid data.
780+
/// Decode a UTF-16LE–encoded vector `v` into a `String`,
781+
/// returning [`Err`] if `v` contains any invalid data.
782782
///
783783
/// # Examples
784784
///
@@ -852,8 +852,8 @@ impl String {
852852
}
853853
}
854854

855-
/// Decode a UTF-16BE–encoded vector `v` into a `String`, returning [`Err`]
856-
/// if `v` contains any invalid data.
855+
/// Decode a UTF-16BE–encoded vector `v` into a `String`,
856+
/// returning [`Err`] if `v` contains any invalid data.
857857
///
858858
/// # Examples
859859
///

‎core/src/char/methods.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl char {
9292
#[stable(feature = "assoc_char_consts", since = "1.52.0")]
9393
pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION;
9494

95-
/// Creates an iterator over the UTF-16 encoded code points in `iter`,
95+
/// Creates an iterator over the native endian UTF-16 encoded code points in `iter`,
9696
/// returning unpaired surrogates as `Err`s.
9797
///
9898
/// # Examples
@@ -704,7 +704,7 @@ impl char {
704704
unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
705705
}
706706

707-
/// Encodes this character as UTF-16 into the provided `u16` buffer,
707+
/// Encodes this character as native endian UTF-16 into the provided `u16` buffer,
708708
/// and then returns the subslice of the buffer that contains the encoded character.
709709
///
710710
/// # Panics
@@ -1828,7 +1828,7 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
18281828
unsafe { slice::from_raw_parts_mut(dst.as_mut_ptr(), len) }
18291829
}
18301830

1831-
/// Encodes a raw `u32` value as UTF-16 into the provided `u16` buffer,
1831+
/// Encodes a raw `u32` value as native endian UTF-16 into the provided `u16` buffer,
18321832
/// and then returns the subslice of the buffer that contains the encoded character.
18331833
///
18341834
/// Unlike `char::encode_utf16`, this method also handles codepoints in the surrogate range.

‎core/src/str/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,8 @@ impl str {
11081108
LinesAny(self.lines())
11091109
}
11101110

1111-
/// Returns an iterator of `u16` over the string encoded as UTF-16.
1111+
/// Returns an iterator of `u16` over the string encoded
1112+
/// as native endian UTF-16 (without byte-order mark).
11121113
///
11131114
/// # Examples
11141115
///

0 commit comments

Comments
 (0)
Please sign in to comment.