Skip to main content

Unicode

Enum Unicode 

Source
pub enum Unicode {}
Expand description

Namespace for Unicode constants and encoding-independent code point helpers.

Implementations§

Source§

impl Unicode

Source

pub const MAX_CODE_POINT: u32 = 0x10ffff

Maximum valid Unicode code point.

Source

pub const REPLACEMENT_CHARACTER: char = '\u{fffd}'

Unicode replacement character.

Source

pub const BOM: char = '\u{feff}'

Unicode byte order mark character.

Source

pub const ASCII_MAX: u32 = 0x7f

Maximum valid ASCII code point.

Source

pub const LATIN1_MAX: u32 = 0xff

Maximum valid Latin-1 code point.

Source

pub const SUPPLEMENTARY_MIN: u32 = 0x10000

Minimum supplementary code point.

Source

pub const HIGH_SURROGATE_MIN: u32 = 0xd800

Minimum high-surrogate code unit value.

Source

pub const HIGH_SURROGATE_MAX: u32 = 0xdbff

Maximum high-surrogate code unit value.

Source

pub const LOW_SURROGATE_MIN: u32 = 0xdc00

Minimum low-surrogate code unit value.

Source

pub const LOW_SURROGATE_MAX: u32 = 0xdfff

Maximum low-surrogate code unit value.

Source

pub const SURROGATE_MIN: u32 = Self::HIGH_SURROGATE_MIN

Minimum surrogate code unit value.

Source

pub const SURROGATE_MAX: u32 = Self::LOW_SURROGATE_MAX

Maximum surrogate code unit value.

Source

pub const fn is_code_point(value: u32) -> bool

Tests whether value is in the Unicode code point range.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true for values in 0x0000..=0x10FFFF, including surrogate code points.

Source

pub const fn is_scalar_value(value: u32) -> bool

Tests whether value is a valid Unicode scalar value.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true for Unicode code points excluding UTF-16 surrogate values.

Source

pub const fn is_surrogate(value: u32) -> bool

Tests whether value is a UTF-16 surrogate code point.

§Parameters
  • value: The raw code point or code-unit value to test.
§Returns

Returns true if value is in 0xD800..=0xDFFF.

Source

pub const fn is_high_surrogate(value: u32) -> bool

Tests whether value is a high surrogate.

§Parameters
  • value: The raw code point or code-unit value to test.
§Returns

Returns true if value is in 0xD800..=0xDBFF.

Source

pub const fn is_low_surrogate(value: u32) -> bool

Tests whether value is a low surrogate.

§Parameters
  • value: The raw code point or code-unit value to test.
§Returns

Returns true if value is in 0xDC00..=0xDFFF.

Source

pub const fn is_bmp(value: u32) -> bool

Tests whether value is in the basic multilingual plane.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true if value is in 0x0000..=0xFFFF.

Source

pub const fn is_supplementary(value: u32) -> bool

Tests whether value is a supplementary Unicode code point.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true if value is in 0x10000..=0x10FFFF.

Source

pub const fn is_ascii(value: u32) -> bool

Tests whether value is an ASCII code point.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true if value is in 0x00..=0x7F.

Source

pub const fn is_noncharacter(value: u32) -> bool

Tests whether value is a Unicode noncharacter.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true for Unicode noncharacters such as U+FDD0..=U+FDEF and code points ending in FFFE or FFFF.

Source

pub const fn is_control(value: u32) -> bool

Tests whether value is a Unicode C0, C1, or DEL control code point.

§Parameters
  • value: The raw code point value to test.
§Returns

Returns true for U+0000..=U+001F, U+007F, and U+0080..=U+009F.

Source

pub const fn plane(value: u32) -> Option<u32>

Returns the Unicode plane containing value.

§Parameters
  • value: The raw code point value to inspect.
§Returns

Returns Some(plane) for Unicode code points, or None for values above U+10FFFF.

Source

pub fn to_char(value: u32) -> Option<char>

Converts a raw code point into a Rust char.

§Parameters
  • value: The raw code point value to convert.
§Returns

Returns Some(char) for valid Unicode scalar values and None otherwise.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.