@@ -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 > {
@@ -276,7 +276,7 @@ impl String {
276
276
/// 0xD834];
277
277
///
278
278
/// assert_eq!(String::from_utf16_lossy(v),
279
- /// "𝄞mus\uFFFDic\uFFFD ".to_string());
279
+ /// "𝄞mus\u{FFFD}ic\u{FFFD} ".to_string());
280
280
/// ```
281
281
#[ stable]
282
282
pub fn from_utf16_lossy ( v : & [ u16 ] ) -> String {
@@ -1057,32 +1057,32 @@ mod tests {
1057
1057
1058
1058
let xs = b"Hello\xC2 There\xFF Goodbye" ;
1059
1059
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( ) ) ;
1061
1061
1062
1062
let xs = b"Hello\xC0 \x80 There\xE6 \x83 Goodbye" ;
1063
1063
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( ) ) ;
1065
1065
1066
1066
let xs = b"\xF5 foo\xF5 \x80 bar" ;
1067
1067
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( ) ) ;
1069
1069
1070
1070
let xs = b"\xF1 foo\xF1 \x80 bar\xF1 \x80 \x80 baz" ;
1071
1071
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( ) ) ;
1073
1073
1074
1074
let xs = b"\xF4 foo\xF4 \x80 bar\xF4 \xBF baz" ;
1075
1075
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( ) ) ;
1077
1077
1078
1078
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( ) ) ;
1081
1081
1082
1082
// surrogates
1083
1083
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( ) ) ;
1086
1086
}
1087
1087
1088
1088
#[ test]
@@ -1124,7 +1124,7 @@ mod tests {
1124
1124
0xd801_u16 , 0xdc95_u16 , 0xd801_u16 , 0xdc86_u16 ,
1125
1125
0x000a_u16 ] ) ,
1126
1126
// Issue #12318, even-numbered non-BMP planes
1127
- ( String :: from_str ( "\U 00020000 " ) ,
1127
+ ( String :: from_str ( "\u{20000} " ) ,
1128
1128
vec ! [ 0xD840 , 0xDC00 ] ) ] ;
1129
1129
1130
1130
for p in pairs. iter ( ) {
@@ -1162,16 +1162,17 @@ mod tests {
1162
1162
fn test_from_utf16_lossy ( ) {
1163
1163
// completely positive cases tested above.
1164
1164
// 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} " ) ) ;
1166
1166
// 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} " ) ) ;
1168
1169
1169
1170
// 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} " ) ) ;
1171
1172
1172
1173
// general
1173
1174
assert_eq ! ( String :: from_utf16_lossy( & [ 0xD800 , 0xd801 , 0xdc8b , 0xD800 ] ) ,
1174
- String :: from_str( "\uFFFD 𐒋 \uFFFD " ) ) ;
1175
+ String :: from_str( "\u{FFFD} 𐒋 \u{FFFD} " ) ) ;
1175
1176
}
1176
1177
1177
1178
#[ test]
@@ -1263,7 +1264,7 @@ mod tests {
1263
1264
#[ test]
1264
1265
#[ should_fail]
1265
1266
fn test_str_truncate_split_codepoint ( ) {
1266
- let mut s = String :: from_str ( "\u00FC " ) ; // ü
1267
+ let mut s = String :: from_str ( "\u{FC} " ) ; // ü
1267
1268
s. truncate ( 1 ) ;
1268
1269
}
1269
1270
0 commit comments