]> git.lizzy.rs Git - rust.git/commitdiff
Escape the unmatched surrogates with lower-case hexadecimal numbers
authorTobias Bucher <tobiasbucher5991@gmail.com>
Thu, 28 Jul 2016 09:30:38 +0000 (11:30 +0200)
committerTobias Bucher <tobiasbucher5991@gmail.com>
Thu, 28 Jul 2016 22:52:03 +0000 (00:52 +0200)
It's done the same way for the rest of the codepoint escapes.

src/libstd/sys/common/wtf8.rs

index c0e6ec46b55b9537d4a152fc6318bca224730f34..c1b4f8a8c88c501d9dc174c8f7186001a9f37b15 100644 (file)
@@ -408,7 +408,7 @@ fn write_str_escaped(f: &mut fmt::Formatter, s: &str) -> fmt::Result {
                             &self.bytes[pos .. surrogate_pos]
                         )},
                     )?;
-                    write!(formatter, "\\u{{{:X}}}", surrogate)?;
+                    write!(formatter, "\\u{{{:x}}}", surrogate)?;
                     pos = surrogate_pos + 3;
                 }
             }
@@ -1066,7 +1066,7 @@ fn c(value: &u32) -> CodePoint { CodePoint::from_u32(*value).unwrap() }
     fn wtf8buf_show() {
         let mut string = Wtf8Buf::from_str("a\té \u{7f}💩\r");
         string.push(CodePoint::from_u32(0xD800).unwrap());
-        assert_eq!(format!("{:?}", string), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{D800}\"");
+        assert_eq!(format!("{:?}", string), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{d800}\"");
     }
 
     #[test]