about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/std/src/sys/windows/stdio.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/sys/windows/stdio.rs b/library/std/src/sys/windows/stdio.rs
index 0812fa51f07..19fd900580b 100644
--- a/library/std/src/sys/windows/stdio.rs
+++ b/library/std/src/sys/windows/stdio.rs
@@ -128,7 +128,8 @@ fn write(
     let utf8 = match str::from_utf8(&data[..len]) {
         Ok(s) => s,
         Err(ref e) if e.valid_up_to() == 0 => {
-            if data.len() < utf8_char_width(data[0]) {
+            first_byte_char_width = utf8_char_width(data[0]);
+            if first_byte_char_width > 1 && data.len() < first_byte_char_width {
                 incomplete_utf8.bytes[0] = data[0];
                 incomplete_utf8.len = 1;
                 return Ok(1);