about summary refs log tree commit diff
path: root/src/libstd/sys/common/wtf8.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sys/common/wtf8.rs')
-rw-r--r--src/libstd/sys/common/wtf8.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs
index f64f835e198..55e485e5811 100644
--- a/src/libstd/sys/common/wtf8.rs
+++ b/src/libstd/sys/common/wtf8.rs
@@ -191,8 +191,11 @@ impl Wtf8Buf {
             match item {
                 Ok(ch) => string.push_char(ch),
                 Err(surrogate) => {
+                    let surrogate = surrogate.unpaired_surrogate();
                     // Surrogates are known to be in the code point range.
-                    let code_point = unsafe { CodePoint::from_u32_unchecked(surrogate as u32) };
+                    let code_point = unsafe {
+                        CodePoint::from_u32_unchecked(surrogate as u32)
+                    };
                     // Skip the WTF-8 concatenation check,
                     // surrogate pairs are already decoded by decode_utf16
                     string.push_code_point_unchecked(code_point)