From ae6adf335c88cad4e4a1805a805ac49dd1350174 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 5 Apr 2018 15:45:33 +0200 Subject: Move char::REPLACEMENT_CHARACTER to libcore --- src/libcore/char.rs | 8 ++++++++ src/libstd_unicode/char.rs | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 718c6b893ed..b5554a59db5 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -77,6 +77,14 @@ const MAX_THREE_B: u32 = 0x10000; #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: char = '\u{10ffff}'; +/// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a +/// decoding error. +/// +/// It can occur, for example, when giving ill-formed UTF-8 bytes to +/// [`String::from_utf8_lossy`](../../std/string/struct.String.html#method.from_utf8_lossy). +#[stable(feature = "decode_utf16", since = "1.9.0")] +pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}'; + /// Converts a `u32` to a `char`. /// /// Note that all [`char`]s are valid [`u32`]s, and can be cast to one with diff --git a/src/libstd_unicode/char.rs b/src/libstd_unicode/char.rs index 33e47ade8cb..460f83d875a 100644 --- a/src/libstd_unicode/char.rs +++ b/src/libstd_unicode/char.rs @@ -38,6 +38,8 @@ use tables::{conversions, derived_property, general_category, property}; pub use core::char::{MAX, from_digit, from_u32, from_u32_unchecked}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode}; +#[stable(feature = "decode_utf16", since = "1.9.0")] +pub use core::char::REPLACEMENT_CHARACTER; #[stable(feature = "char_from_str", since = "1.20.0")] pub use core::char::ParseCharError; @@ -1581,11 +1583,3 @@ impl fmt::Display for DecodeUtf16Error { write!(f, "unpaired surrogate found: {:x}", self.code) } } - -/// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a -/// decoding error. -/// -/// It can occur, for example, when giving ill-formed UTF-8 bytes to -/// [`String::from_utf8_lossy`](../../std/string/struct.String.html#method.from_utf8_lossy). -#[stable(feature = "decode_utf16", since = "1.9.0")] -pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}'; -- cgit 1.4.1-3-g733a5