@@ -118,7 +118,7 @@ impl String {
118
118
/// ```rust
119
119
/// let input = b"Hello \xF0\x90\x80World";
120
120
/// 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 ");
122
122
/// ```
123
123
#[ unstable = "return type may change" ]
124
124
pub fn from_utf8_lossy < ' a > ( v : & ' a [ u8 ] ) -> CowString < ' a > {
@@ -275,7 +275,7 @@ impl String {
275
275
/// 0xD834];
276
276
///
277
277
/// assert_eq!(String::from_utf16_lossy(v),
278
- /// "𝄞mus\uFFFDic\uFFFD ".to_string());
278
+ /// "𝄞mus\u{FFFD}ic\u{FFFD} ".to_string());
279
279
/// ```
280
280
#[ stable]
281
281
pub fn from_utf16_lossy ( v : & [ u16 ] ) -> String {
@@ -1043,32 +1043,32 @@ mod tests {
1043
1043
1044
1044
let xs = b"Hello\xC2 There\xFF Goodbye" ;
1045
1045
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( ) ) ;
1047
1047
1048
1048
let xs = b"Hello\xC0 \x80 There\xE6 \x83 Goodbye" ;
1049
1049
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( ) ) ;
1051
1051
1052
1052
let xs = b"\xF5 foo\xF5 \x80 bar" ;
1053
1053
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( ) ) ;
1055
1055
1056
1056
let xs = b"\xF1 foo\xF1 \x80 bar\xF1 \x80 \x80 baz" ;
1057
1057
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( ) ) ;
1059
1059
1060
1060
let xs = b"\xF4 foo\xF4 \x80 bar\xF4 \xBF baz" ;
1061
1061
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( ) ) ;
1063
1063
1064
1064
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( ) ) ;
1067
1067
1068
1068
// surrogates
1069
1069
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( ) ) ;
1072
1072
}
1073
1073
1074
1074
#[ test]
@@ -1110,7 +1110,7 @@ mod tests {
1110
1110
0xd801_u16 , 0xdc95_u16 , 0xd801_u16 , 0xdc86_u16 ,
1111
1111
0x000a_u16 ] ) ,
1112
1112
// Issue #12318, even-numbered non-BMP planes
1113
- ( String :: from_str ( "\U 00020000 " ) ,
1113
+ ( String :: from_str ( "\u{20000} " ) ,
1114
1114
vec ! [ 0xD840 , 0xDC00 ] ) ] ;
1115
1115
1116
1116
for p in pairs. iter ( ) {
@@ -1148,16 +1148,17 @@ mod tests {
1148
1148
fn test_from_utf16_lossy ( ) {
1149
1149
// completely positive cases tested above.
1150
1150
// 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} " ) ) ;
1152
1152
// 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} " ) ) ;
1154
1155
1155
1156
// 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} " ) ) ;
1157
1158
1158
1159
// general
1159
1160
assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xd801 , 0xdc8b , 0xD800 ] ) ,
1160
- String :: from_str( "\uFFFD 𐒋 \uFFFD " ) ) ;
1161
+ String :: from_str( "\u{FFFD} 𐒋 \u{FFFD} " ) ) ;
1161
1162
}
1162
1163
1163
1164
#[ test]
@@ -1249,7 +1250,7 @@ mod tests {
1249
1250
#[ test]
1250
1251
#[ should_fail]
1251
1252
fn test_str_truncate_split_codepoint ( ) {
1252
- let mut s = String :: from_str ( "\u00FC " ) ; // ü
1253
+ let mut s = String :: from_str ( "\u{FC} " ) ; // ü
1253
1254
s. truncate ( 1 ) ;
1254
1255
}
1255
1256
0 commit comments