@@ -118,7 +118,7 @@ impl String {
118118 /// ```rust
119119 /// let input = b"Hello \xF0\x90\x80World";
120120 /// let output = String::from_utf8_lossy(input);
121- /// assert_eq!(output.as_slice(), "Hello \uFFFDWorld ");
121+ /// assert_eq!(output.as_slice(), "Hello \u{FFFD}World ");
122122 /// ```
123123 #[ unstable = "return type may change" ]
124124 pub fn from_utf8_lossy < ' a > ( v : & ' a [ u8 ] ) -> CowString < ' a > {
@@ -276,7 +276,7 @@ impl String {
276276 /// 0xD834];
277277 ///
278278 /// assert_eq!(String::from_utf16_lossy(v),
279- /// "𝄞mus\uFFFDic\uFFFD ".to_string());
279+ /// "𝄞mus\u{FFFD}ic\u{FFFD} ".to_string());
280280 /// ```
281281 #[ stable]
282282 pub fn from_utf16_lossy ( v : & [ u16 ] ) -> String {
@@ -1057,32 +1057,32 @@ mod tests {
10571057
10581058 let xs = b"Hello\xC2 There\xFF Goodbye" ;
10591059 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1060- String :: from_str( "Hello\uFFFD There\uFFFD Goodbye" ) . into_cow( ) ) ;
1060+ String :: from_str( "Hello\u{FFFD} There\u{FFFD} Goodbye" ) . into_cow( ) ) ;
10611061
10621062 let xs = b"Hello\xC0 \x80 There\xE6 \x83 Goodbye" ;
10631063 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1064- String :: from_str( "Hello\uFFFD \uFFFD There\uFFFD Goodbye" ) . into_cow( ) ) ;
1064+ String :: from_str( "Hello\u{FFFD} \u{FFFD} There\u{FFFD} Goodbye" ) . into_cow( ) ) ;
10651065
10661066 let xs = b"\xF5 foo\xF5 \x80 bar" ;
10671067 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1068- String :: from_str( "\uFFFD foo \uFFFD \uFFFD bar " ) . into_cow( ) ) ;
1068+ String :: from_str( "\u{FFFD} foo \u{FFFD} \u{FFFD} bar " ) . into_cow( ) ) ;
10691069
10701070 let xs = b"\xF1 foo\xF1 \x80 bar\xF1 \x80 \x80 baz" ;
10711071 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1072- String :: from_str( "\uFFFD foo \uFFFD bar \uFFFD baz " ) . into_cow( ) ) ;
1072+ String :: from_str( "\u{FFFD} foo \u{FFFD} bar \u{FFFD} baz " ) . into_cow( ) ) ;
10731073
10741074 let xs = b"\xF4 foo\xF4 \x80 bar\xF4 \xBF baz" ;
10751075 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1076- String :: from_str( "\uFFFD foo \uFFFD bar \uFFFD \uFFFD baz " ) . into_cow( ) ) ;
1076+ String :: from_str( "\u{FFFD} foo \u{FFFD} bar \u{FFFD} \u{FFFD} baz " ) . into_cow( ) ) ;
10771077
10781078 let xs = b"\xF0 \x80 \x80 \x80 foo\xF0 \x90 \x80 \x80 bar" ;
1079- assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\uFFFD \uFFFD \uFFFD \uFFFD \
1080- foo\U 00010000bar ") . into_cow( ) ) ;
1079+ assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\u{FFFD} \u{FFFD} \u{FFFD} \u{FFFD} \
1080+ foo\u{10000} bar ") . into_cow( ) ) ;
10811081
10821082 // surrogates
10831083 let xs = b"\xED \xA0 \x80 foo\xED \xBF \xBF bar" ;
1084- assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\uFFFD \uFFFD \uFFFD foo \
1085- \uFFFD \uFFFD \uFFFD bar ") . into_cow( ) ) ;
1084+ assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\u{FFFD} \u{FFFD} \u{FFFD} foo \
1085+ \u{FFFD} \u{FFFD} \u{FFFD} bar ") . into_cow( ) ) ;
10861086 }
10871087
10881088 #[ test]
@@ -1124,7 +1124,7 @@ mod tests {
11241124 0xd801_u16 , 0xdc95_u16 , 0xd801_u16 , 0xdc86_u16 ,
11251125 0x000a_u16 ] ) ,
11261126 // Issue #12318, even-numbered non-BMP planes
1127- ( String :: from_str ( "\U 00020000 " ) ,
1127+ ( String :: from_str ( "\u{20000} " ) ,
11281128 vec ! [ 0xD840 , 0xDC00 ] ) ] ;
11291129
11301130 for p in pairs. iter ( ) {
@@ -1162,16 +1162,17 @@ mod tests {
11621162 fn test_from_utf16_lossy ( ) {
11631163 // completely positive cases tested above.
11641164 // lead + eof
1165- assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 ] ) , String :: from_str( "\uFFFD " ) ) ;
1165+ assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 ] ) , String :: from_str( "\u{FFFD} " ) ) ;
11661166 // lead + lead
1167- assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xD800 ] ) , String :: from_str( "\uFFFD \uFFFD " ) ) ;
1167+ assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xD800 ] ) ,
1168+ String :: from_str( "\u{FFFD} \u{FFFD} " ) ) ;
11681169
11691170 // isolated trail
1170- assert_eq ! ( String :: from_utf16_lossy( & [ 0x0061 , 0xDC00 ] ) , String :: from_str( "a\uFFFD " ) ) ;
1171+ assert_eq ! ( String :: from_utf16_lossy( & [ 0x0061 , 0xDC00 ] ) , String :: from_str( "a\u{FFFD} " ) ) ;
11711172
11721173 // general
11731174 assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xd801 , 0xdc8b , 0xD800 ] ) ,
1174- String :: from_str( "\uFFFD 𐒋 \uFFFD " ) ) ;
1175+ String :: from_str( "\u{FFFD} 𐒋 \u{FFFD} " ) ) ;
11751176 }
11761177
11771178 #[ test]
@@ -1263,7 +1264,7 @@ mod tests {
12631264 #[ test]
12641265 #[ should_fail]
12651266 fn test_str_truncate_split_codepoint ( ) {
1266- let mut s = String :: from_str ( "\u00FC " ) ; // ü
1267+ let mut s = String :: from_str ( "\u{FC} " ) ; // ü
12671268 s. truncate ( 1 ) ;
12681269 }
12691270
0 commit comments