Trait std::char::CharExperimental
[-]
[+]
[src]
pub trait Char {
fn is_digit_radix(self, radix: uint) -> bool;
fn is_digit(self, radix: uint) -> bool;
fn to_digit(self, radix: uint) -> Option<uint>;
fn from_digit(num: uint, radix: uint) -> Option<Self>;
fn from_u32(i: u32) -> Option<char>;
fn escape_unicode(self) -> EscapeUnicode;
fn escape_default(self) -> EscapeDefault;
fn len_utf8_bytes(self) -> uint;
fn len_utf8(self) -> uint;
fn len_utf16(self) -> uint;
fn encode_utf8(&self, dst: &mut [u8]) -> Option<uint>;
fn encode_utf16(&self, dst: &mut [u16]) -> Option<uint>;
}Basic char manipulations.
Required Methods
fn is_digit_radix(self, radix: uint) -> bool
Checks if a char parses as a numeric digit in the given radix.
Compared to is_numeric(), this function only recognizes the characters
0-9, a-z and A-Z.
Return value
Returns true if c is a valid digit under radix, and false
otherwise.
Panics
Panics if given a radix > 36.
fn is_digit(self, radix: uint) -> bool
Checks if a char parses as a numeric digit in the given radix.
Compared to is_numeric(), this function only recognizes the characters
0-9, a-z and A-Z.
Return value
Returns true if c is a valid digit under radix, and false
otherwise.
Panics
Panics if given a radix > 36.
fn to_digit(self, radix: uint) -> Option<uint>
Converts a character to the corresponding digit.
Return value
If c is between '0' and '9', the corresponding value between 0 and
9. If c is 'a' or 'A', 10. If c is 'b' or 'B', 11, etc. Returns
none if the character does not refer to a digit in the given radix.
Panics
Panics if given a radix outside the range [0..36].
fn from_digit(num: uint, radix: uint) -> Option<Self>
Converts a number to the character representing it.
Return value
Returns Some(char) if num represents one digit under radix,
using one character of 0-9 or a-z, or None if it doesn't.
Panics
Panics if given a radix > 36.
fn from_u32(i: u32) -> Option<char>
Converts from u32 to a char
fn escape_unicode(self) -> EscapeUnicode
Returns an iterator that yields the hexadecimal Unicode escape
of a character, as chars.
All characters are escaped with Rust syntax of the form \\u{NNNN}
where NNNN is the shortest hexadecimal representation of the code
point.
fn escape_default(self) -> EscapeDefault
Returns an iterator that yields the 'default' ASCII and
C++11-like literal escape of a character, as chars.
The default is chosen with a bias toward producing literals that are legal in a variety of languages, including C++11 and similar C-family languages. The exact rules are:
- Tab, CR and LF are escaped as '\t', '\r' and '\n' respectively.
- Single-quote, double-quote and backslash chars are backslash- escaped.
- Any other chars in the range [0x20,0x7e] are not escaped.
- Any other chars are given hex Unicode escapes; see
escape_unicode.
fn len_utf8_bytes(self) -> uint
Returns the amount of bytes this character would need if encoded in UTF-8.
fn len_utf8(self) -> uint
Returns the amount of bytes this character would need if encoded in UTF-8.
fn len_utf16(self) -> uint
Returns the amount of bytes this character would need if encoded in UTF-16.
fn encode_utf8(&self, dst: &mut [u8]) -> Option<uint>
Encodes this character as UTF-8 into the provided byte buffer, and then returns the number of bytes written.
If the buffer is not large enough, nothing will be written into it
and a None will be returned.
fn encode_utf16(&self, dst: &mut [u16]) -> Option<uint>
Encodes this character as UTF-16 into the provided u16 buffer,
and then returns the number of u16s written.
If the buffer is not large enough, nothing will be written into it
and a None will be returned.