Struct std::sys_common::wtf8::CodePoint
source · pub struct CodePoint {
value: u32,
}
Expand description
A Unicode code point: from U+0000 to U+10FFFF.
Compares with the char
type,
which represents a Unicode scalar value:
a code point that is not a surrogate (U+D800 to U+DFFF).
Fields§
§value: u32
Implementations§
source§impl CodePoint
impl CodePoint
sourcepub unsafe fn from_u32_unchecked(value: u32) -> CodePoint
pub unsafe fn from_u32_unchecked(value: u32) -> CodePoint
Unsafely creates a new CodePoint
without checking the value.
Only use when value
is known to be less than or equal to 0x10FFFF.
sourcepub fn from_u32(value: u32) -> Option<CodePoint>
pub fn from_u32(value: u32) -> Option<CodePoint>
Creates a new CodePoint
if the value is a valid code point.
Returns None
if value
is above 0x10FFFF.
sourcepub fn from_char(value: char) -> CodePoint
pub fn from_char(value: char) -> CodePoint
Creates a new CodePoint
from a char
.
Since all Unicode scalar values are code points, this always succeeds.
sourcepub fn to_lead_surrogate(&self) -> Option<u16>
pub fn to_lead_surrogate(&self) -> Option<u16>
Returns the numeric value of the code point if it is a leading surrogate.
sourcepub fn to_trail_surrogate(&self) -> Option<u16>
pub fn to_trail_surrogate(&self) -> Option<u16>
Returns the numeric value of the code point if it is a trailing surrogate.
sourcepub fn to_char(&self) -> Option<char>
pub fn to_char(&self) -> Option<char>
Optionally returns a Unicode scalar value for the code point.
Returns None
if the code point is a surrogate (from U+D800 to U+DFFF).
sourcepub fn to_char_lossy(&self) -> char
pub fn to_char_lossy(&self) -> char
Returns a Unicode scalar value for the code point.
Returns '\u{FFFD}'
(the replacement character “�”)
if the code point is a surrogate (from U+D800 to U+DFFF).
Trait Implementations§
source§impl Debug for CodePoint
impl Debug for CodePoint
Format the code point as U+
followed by four to six hexadecimal digits.
Example: U+1F4A9
source§impl Extend<CodePoint> for Wtf8Buf
impl Extend<CodePoint> for Wtf8Buf
Append code points from an iterator to the string.
This replaces surrogate code point pairs with supplementary code points, like concatenating ill-formed UTF-16 strings effectively would.
source§impl FromIterator<CodePoint> for Wtf8Buf
impl FromIterator<CodePoint> for Wtf8Buf
Creates a new WTF-8 string from an iterator of code points.
This replaces surrogate code point pairs with supplementary code points, like concatenating ill-formed UTF-16 strings effectively would.
source§impl Ord for CodePoint
impl Ord for CodePoint
source§impl PartialEq<CodePoint> for CodePoint
impl PartialEq<CodePoint> for CodePoint
source§impl PartialOrd<CodePoint> for CodePoint
impl PartialOrd<CodePoint> for CodePoint
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more