Trait std::char::UnicodeCharExperimental
[-]
[+]
[src]
pub trait UnicodeChar { fn is_alphabetic(self) -> bool; fn is_XID_start(self) -> bool; fn is_xid_start(self) -> bool; fn is_XID_continue(self) -> bool; fn is_xid_continue(self) -> bool; fn is_lowercase(self) -> bool; fn is_uppercase(self) -> bool; fn is_whitespace(self) -> bool; fn is_alphanumeric(self) -> bool; fn is_control(self) -> bool; fn is_numeric(self) -> bool; fn to_lowercase(self) -> char; fn to_uppercase(self) -> char; fn width(self, is_cjk: bool) -> Option<uint>; }
Useful functions for Unicode characters.
Required Methods
fn is_alphabetic(self) -> bool
Returns whether the specified character is considered a Unicode alphabetic code point.
fn is_XID_start(self) -> bool
Returns whether the specified character satisfies the 'XID_Start' Unicode property.
'XID_Start' is a Unicode Derived Property specified in UAX #31, mostly similar to ID_Start but modified for closure under NFKx.
fn is_xid_start(self) -> bool
Returns whether the specified character satisfies the 'XID_Start' Unicode property.
'XID_Start' is a Unicode Derived Property specified in UAX #31, mostly similar to ID_Start but modified for closure under NFKx.
fn is_XID_continue(self) -> bool
Returns whether the specified char
satisfies the 'XID_Continue'
Unicode property.
'XID_Continue' is a Unicode Derived Property specified in UAX #31, mostly similar to 'ID_Continue' but modified for closure under NFKx.
fn is_xid_continue(self) -> bool
Returns whether the specified char
satisfies the 'XID_Continue'
Unicode property.
'XID_Continue' is a Unicode Derived Property specified in UAX #31, mostly similar to 'ID_Continue' but modified for closure under NFKx.
fn is_lowercase(self) -> bool
Indicates whether a character is in lowercase.
This is defined according to the terms of the Unicode Derived Core
Property Lowercase
.
fn is_uppercase(self) -> bool
Indicates whether a character is in uppercase.
This is defined according to the terms of the Unicode Derived Core
Property Uppercase
.
fn is_whitespace(self) -> bool
Indicates whether a character is whitespace.
Whitespace is defined in terms of the Unicode Property White_Space
.
fn is_alphanumeric(self) -> bool
Indicates whether a character is alphanumeric.
Alphanumericness is defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
fn is_control(self) -> bool
Indicates whether a character is a control code point.
Control code points are defined in terms of the Unicode General
Category Cc
.
fn is_numeric(self) -> bool
Indicates whether the character is numeric (Nd, Nl, or No).
fn to_lowercase(self) -> char
Converts a character to its lowercase equivalent.
The case-folding performed is the common or simple mapping. See
to_uppercase()
for references and more information.
Return value
Returns the lowercase equivalent of the character, or the character itself if no conversion is possible.
fn to_uppercase(self) -> char
Converts a character to its uppercase equivalent.
The case-folding performed is the common or simple mapping: it maps
one Unicode codepoint (one character in Rust) to its uppercase
equivalent according to the Unicode database 1. The additional
[SpecialCasing.txt
] is not considered here, as it expands to multiple
codepoints in some cases.
A full reference can be found here 2.
Return value
Returns the uppercase equivalent of the character, or the character itself if no conversion was made.
fn width(self, is_cjk: bool) -> Option<uint>
Returns this character's displayed width in columns, or None
if it is a
control character other than '\x00'
.
is_cjk
determines behavior for characters in the Ambiguous category:
if is_cjk
is true
, these are 2 columns wide; otherwise, they are 1.
In CJK contexts, is_cjk
should be true
, else it should be false
.
Unicode Standard Annex #11
recommends that these characters be treated as 1 column (i.e.,
is_cjk
= false
) if the context cannot be reliably determined.
Implementors
impl UnicodeChar for char