Utilities for manipulating the char type
Char
of Char for char
of Eq for char
of Ord for char
of Zero for char
escape_default
- Return a 'default' ASCII and C++11-like char-literal escape of a char.escape_unicode
- Return the hexadecimal unicode escape of a char.from_digit
- Converts a number to the character representing it.is_XID_continue
is_XID_start
is_alphabetic
- Returns whether the specified character is considered a unicode alphabetic characteris_alphanumeric
- Indicates whether a character is alphanumericis_digit
- Indicates whether the character is numeric (Nd, Nl, or No)is_digit_radix
- Checks if a character parses as a numeric digit in the given radixis_lowercase
- Indicates whether a character is in lower case, defined in terms of the Unicode General Category 'Ll'is_uppercase
- Indicates whether a character is in upper case, defined in terms of the Unicode General Category 'Lu'.is_whitespace
- Indicates whether a character is whitespacelen_utf8_bytes
- Returns the amount of bytes this character would need if encoded in utf8to_digit
- Convert a char to the corresponding digit.Char
is_alphabetic
fn is_alphabetic(&self) -> bool
is_XID_start
fn is_XID_start(&self) -> bool
is_XID_continue
fn is_XID_continue(&self) -> bool
is_lowercase
fn is_lowercase(&self) -> bool
is_uppercase
fn is_uppercase(&self) -> bool
is_whitespace
fn is_whitespace(&self) -> bool
is_alphanumeric
fn is_alphanumeric(&self) -> bool
is_digit
fn is_digit(&self) -> bool
is_digit_radix
fn is_digit_radix(&self, radix: uint) -> bool
to_digit
fn to_digit(&self, radix: uint) -> Option<uint>
from_digit
fn from_digit(num: uint, radix: uint) -> Option<char>
escape_unicode
fn escape_unicode(&self, f: &fn(char))
escape_default
fn escape_default(&self, f: &fn(char))
len_utf8_bytes
fn len_utf8_bytes(&self) -> uint
Char
for char
is_alphabetic
fn is_alphabetic(&self) -> bool
is_XID_start
fn is_XID_start(&self) -> bool
is_XID_continue
fn is_XID_continue(&self) -> bool
is_lowercase
fn is_lowercase(&self) -> bool
is_uppercase
fn is_uppercase(&self) -> bool
is_whitespace
fn is_whitespace(&self) -> bool
is_alphanumeric
fn is_alphanumeric(&self) -> bool
is_digit
fn is_digit(&self) -> bool
is_digit_radix
fn is_digit_radix(&self, radix: uint) -> bool
to_digit
fn to_digit(&self, radix: uint) -> Option<uint>
from_digit
fn from_digit(num: uint, radix: uint) -> Option<char>
escape_unicode
fn escape_unicode(&self, f: &fn(char))
escape_default
fn escape_default(&self, f: &fn(char))
len_utf8_bytes
fn len_utf8_bytes(&self) -> uint
Eq
for char
eq
fn eq(&self, other: &char) -> bool
ne
fn ne(&self, other: &char) -> bool
Ord
for char
lt
fn lt(&self, other: &char) -> bool
le
fn le(&self, other: &char) -> bool
gt
fn gt(&self, other: &char) -> bool
ge
fn ge(&self, other: &char) -> bool
Zero
for char
zero
fn zero() -> char
is_zero
fn is_zero(&self) -> bool
escape_default
fn escape_default(c: char, f: &fn(char))
Return a 'default' ASCII and C++11-like char-literal escape of a char.
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:
escape_unicode
.escape_unicode
fn escape_unicode(c: char, f: &fn(char))
Return the hexadecimal unicode escape of a char.
The rules are as follows:
\\\\xNN
\\\\uNNNN
\\\\UNNNNNNNN
from_digit
fn from_digit(num: uint, radix: uint) -> Option<char>
Converts a number to the character representing it.
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.
Fails if given an radix
> 36.
is_XID_continue
fn is_XID_continue(c: char) -> bool
is_XID_start
fn is_XID_start(c: char) -> bool
is_alphabetic
fn is_alphabetic(c: char) -> bool
Returns whether the specified character is considered a unicode alphabetic character
is_alphanumeric
fn is_alphanumeric(c: char) -> 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'.
is_digit
fn is_digit(c: char) -> bool
Indicates whether the character is numeric (Nd, Nl, or No)
is_digit_radix
fn is_digit_radix(c: char, radix: uint) -> bool
Checks if a character parses as a numeric digit in the given radix. Compared to is_digit()
, this function only recognizes the characters 0-9
, a-z
and A-Z
.
Returns true
if c
is a valid digit under radix
, and false
otherwise.
Fails if given a radix
> 36.
This just wraps to_digit()
.
is_lowercase
fn is_lowercase(c: char) -> bool
Indicates whether a character is in lower case, defined in terms of the Unicode General Category 'Ll'
is_uppercase
fn is_uppercase(c: char) -> bool
Indicates whether a character is in upper case, defined in terms of the Unicode General Category 'Lu'.
is_whitespace
fn is_whitespace(c: char) -> bool
Indicates whether a character is whitespace. Whitespace is defined in terms of the Unicode General Categories 'Zs', 'Zl', 'Zp' additional 'Cc'-category control codes in the range [0x09, 0x0d]
len_utf8_bytes
fn len_utf8_bytes(c: char) -> uint
Returns the amount of bytes this character would need if encoded in utf8
to_digit
fn to_digit(c: char, radix: uint) -> Option<uint>
Convert a char to the corresponding digit.
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 char does not refer to a digit in the given radix.
Fails if given a radix
outside the range [0..36]
.