Skip to content

Commit ae6adf3

Browse files
committed
Move char::REPLACEMENT_CHARACTER to libcore
1 parent ad610be commit ae6adf3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/libcore/char.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ const MAX_THREE_B: u32 = 0x10000;
7777
#[stable(feature = "rust1", since = "1.0.0")]
7878
pub const MAX: char = '\u{10ffff}';
7979

80+
/// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a
81+
/// decoding error.
82+
///
83+
/// It can occur, for example, when giving ill-formed UTF-8 bytes to
84+
/// [`String::from_utf8_lossy`](../../std/string/struct.String.html#method.from_utf8_lossy).
85+
#[stable(feature = "decode_utf16", since = "1.9.0")]
86+
pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}';
87+
8088
/// Converts a `u32` to a `char`.
8189
///
8290
/// Note that all [`char`]s are valid [`u32`]s, and can be cast to one with

src/libstd_unicode/char.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ use tables::{conversions, derived_property, general_category, property};
3838
pub use core::char::{MAX, from_digit, from_u32, from_u32_unchecked};
3939
#[stable(feature = "rust1", since = "1.0.0")]
4040
pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode};
41+
#[stable(feature = "decode_utf16", since = "1.9.0")]
42+
pub use core::char::REPLACEMENT_CHARACTER;
4143
#[stable(feature = "char_from_str", since = "1.20.0")]
4244
pub use core::char::ParseCharError;
4345

@@ -1581,11 +1583,3 @@ impl fmt::Display for DecodeUtf16Error {
15811583
write!(f, "unpaired surrogate found: {:x}", self.code)
15821584
}
15831585
}
1584-
1585-
/// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a
1586-
/// decoding error.
1587-
///
1588-
/// It can occur, for example, when giving ill-formed UTF-8 bytes to
1589-
/// [`String::from_utf8_lossy`](../../std/string/struct.String.html#method.from_utf8_lossy).
1590-
#[stable(feature = "decode_utf16", since = "1.9.0")]
1591-
pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}';

0 commit comments

Comments
 (0)