ASCII stands for American Standard Code for Information Interchange. It is a way of encoding a character set used for communication between computers. ASCII is the first among many encodings, which also include such encodings as the UTF-8, ISO-8859-1, etc.
A character is said to be ASCII if it is a number from 0 to 9, a letter from A to Z, or some special character.
We can use the is_ascii_alphabetic()
method to check if a character is both an ASCII and a letter of the alphabet. It returns true
if the character is an ASCII and a letter. Otherwise, it returns false
.
character.is_ascii_alphabetic()
character
: This is the character that we are checking to see if it is both an ASCII and an alphabetic letter.
This method returns a boolean value. It returns true
if the character is both an ASCII and a letter. Otherwise, it returns false
.
fn main(){// create some characterslet char1 = 'R';let char2 = '❤'; // non ASCIIlet char3 = 'l';let char4 = 'a';let char5 = '3';// check if ASCII and alphabetic tooprintln!("{}", char1.is_ascii_alphabetic());println!("{}", char2.is_ascii_alphabetic());println!("{}", char3.is_ascii_alphabetic());println!("{}", char4.is_ascii_alphabetic());println!("{}", char5.is_ascii_alphabetic());}
is_ascii_alphabetic()
method to see if they are ASCII and alphabetic. Then we print the result to the console screen.