Skip to content

Commit da85329

Browse files
committed
Describe the maximum size of the decoded buffer
1 parent d2f2cfa commit da85329

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ where
9595
/// Decode UCS-2 string to UTF-8 with a custom callback function.
9696
///
9797
/// `output` is a function which receives every decoded character.
98+
/// Due to the nature of UCS-2, the function can receive an UTF-8 character
99+
/// of up to three bytes, for every input character.
98100
pub fn decode_with<F>(input: &[u16], mut output: F) -> Result<usize>
99101
where
100102
F: FnMut(&[u8]) -> Result<()>,
@@ -134,7 +136,8 @@ where
134136
/// Decode an input UCS-2 string into a UTF-8 string.
135137
///
136138
/// The returned `usize` represents the length of the returned buffer,
137-
/// in bytes.
139+
/// in bytes. Due to the nature of UCS-2, the output buffer could end up with
140+
/// three bytes for every character in the input buffer.
138141
pub fn decode(input: &[u16], output: &mut [u8]) -> Result<usize> {
139142
let buffer_size = output.len();
140143
let mut i = 0;

0 commit comments

Comments
 (0)