@@ -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 > {
@@ -275,7 +275,7 @@ impl String {
275275 /// 0xD834];
276276 ///
277277 /// assert_eq!(String::from_utf16_lossy(v),
278- /// "𝄞mus\uFFFDic\uFFFD ".to_string());
278+ /// "𝄞mus\u{FFFD}ic\u{FFFD} ".to_string());
279279 /// ```
280280 #[ stable]
281281 pub fn from_utf16_lossy ( v : & [ u16 ] ) -> String {
@@ -1043,32 +1043,32 @@ mod tests {
10431043
10441044 let xs = b"Hello\xC2 There\xFF Goodbye" ;
10451045 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1046- String :: from_str( "Hello\uFFFD There\uFFFD Goodbye" ) . into_cow( ) ) ;
1046+ String :: from_str( "Hello\u{FFFD} There\u{FFFD} Goodbye" ) . into_cow( ) ) ;
10471047
10481048 let xs = b"Hello\xC0 \x80 There\xE6 \x83 Goodbye" ;
10491049 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1050- String :: from_str( "Hello\uFFFD \uFFFD There\uFFFD Goodbye" ) . into_cow( ) ) ;
1050+ String :: from_str( "Hello\u{FFFD} \u{FFFD} There\u{FFFD} Goodbye" ) . into_cow( ) ) ;
10511051
10521052 let xs = b"\xF5 foo\xF5 \x80 bar" ;
10531053 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1054- String :: from_str( "\uFFFD foo \uFFFD \uFFFD bar " ) . into_cow( ) ) ;
1054+ String :: from_str( "\u{FFFD} foo \u{FFFD} \u{FFFD} bar " ) . into_cow( ) ) ;
10551055
10561056 let xs = b"\xF1 foo\xF1 \x80 bar\xF1 \x80 \x80 baz" ;
10571057 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1058- String :: from_str( "\uFFFD foo \uFFFD bar \uFFFD baz " ) . into_cow( ) ) ;
1058+ String :: from_str( "\u{FFFD} foo \u{FFFD} bar \u{FFFD} baz " ) . into_cow( ) ) ;
10591059
10601060 let xs = b"\xF4 foo\xF4 \x80 bar\xF4 \xBF baz" ;
10611061 assert_eq ! ( String :: from_utf8_lossy( xs) ,
1062- String :: from_str( "\uFFFD foo \uFFFD bar \uFFFD \uFFFD baz " ) . into_cow( ) ) ;
1062+ String :: from_str( "\u{FFFD} foo \u{FFFD} bar \u{FFFD} \u{FFFD} baz " ) . into_cow( ) ) ;
10631063
10641064 let xs = b"\xF0 \x80 \x80 \x80 foo\xF0 \x90 \x80 \x80 bar" ;
1065- assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\uFFFD \uFFFD \uFFFD \uFFFD \
1066- foo\U 00010000bar ") . into_cow( ) ) ;
1065+ assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\u{FFFD} \u{FFFD} \u{FFFD} \u{FFFD} \
1066+ foo\u{10000} bar ") . into_cow( ) ) ;
10671067
10681068 // surrogates
10691069 let xs = b"\xED \xA0 \x80 foo\xED \xBF \xBF bar" ;
1070- assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\uFFFD \uFFFD \uFFFD foo \
1071- \uFFFD \uFFFD \uFFFD bar ") . into_cow( ) ) ;
1070+ assert_eq ! ( String :: from_utf8_lossy( xs) , String :: from_str( "\u{FFFD} \u{FFFD} \u{FFFD} foo \
1071+ \u{FFFD} \u{FFFD} \u{FFFD} bar ") . into_cow( ) ) ;
10721072 }
10731073
10741074 #[ test]
@@ -1110,7 +1110,7 @@ mod tests {
11101110 0xd801_u16 , 0xdc95_u16 , 0xd801_u16 , 0xdc86_u16 ,
11111111 0x000a_u16 ] ) ,
11121112 // Issue #12318, even-numbered non-BMP planes
1113- ( String :: from_str ( "\U 00020000 " ) ,
1113+ ( String :: from_str ( "\u{20000} " ) ,
11141114 vec ! [ 0xD840 , 0xDC00 ] ) ] ;
11151115
11161116 for p in pairs. iter ( ) {
@@ -1148,16 +1148,17 @@ mod tests {
11481148 fn test_from_utf16_lossy ( ) {
11491149 // completely positive cases tested above.
11501150 // lead + eof
1151- assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 ] ) , String :: from_str( "\uFFFD " ) ) ;
1151+ assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 ] ) , String :: from_str( "\u{FFFD} " ) ) ;
11521152 // lead + lead
1153- assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xD800 ] ) , String :: from_str( "\uFFFD \uFFFD " ) ) ;
1153+ assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xD800 ] ) ,
1154+ String :: from_str( "\u{FFFD} \u{FFFD} " ) ) ;
11541155
11551156 // isolated trail
1156- assert_eq ! ( String :: from_utf16_lossy( & [ 0x0061 , 0xDC00 ] ) , String :: from_str( "a\uFFFD " ) ) ;
1157+ assert_eq ! ( String :: from_utf16_lossy( & [ 0x0061 , 0xDC00 ] ) , String :: from_str( "a\u{FFFD} " ) ) ;
11571158
11581159 // general
11591160 assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xd801 , 0xdc8b , 0xD800 ] ) ,
1160- String :: from_str( "\uFFFD 𐒋 \uFFFD " ) ) ;
1161+ String :: from_str( "\u{FFFD} 𐒋 \u{FFFD} " ) ) ;
11611162 }
11621163
11631164 #[ test]
@@ -1249,7 +1250,7 @@ mod tests {
12491250 #[ test]
12501251 #[ should_fail]
12511252 fn test_str_truncate_split_codepoint ( ) {
1252- let mut s = String :: from_str ( "\u00FC " ) ; // ü
1253+ let mut s = String :: from_str ( "\u{FC} " ) ; // ü
12531254 s. truncate ( 1 ) ;
12541255 }
12551256
0 commit comments