File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ impl Char16 {
8383 pub const unsafe fn from_u16_unchecked ( val : u16 ) -> Self {
8484 Self ( val)
8585 }
86+
87+ /// Checks if the value is within the ASCII range.
88+ #[ must_use]
89+ pub const fn is_ascii ( & self ) -> bool {
90+ self . 0 <= 127
91+ }
8692}
8793
8894impl TryFrom < char > for Char16 {
Original file line number Diff line number Diff line change @@ -415,6 +415,12 @@ impl CStr16 {
415415 self . 0 . len ( ) * 2
416416 }
417417
418+ /// Checks if all characters in this string are within the ASCII range.
419+ #[ must_use]
420+ pub fn is_ascii ( & self ) -> bool {
421+ self . 0 . iter ( ) . all ( |c| c. is_ascii ( ) )
422+ }
423+
418424 /// Writes each [`Char16`] as a [`char`] (4 bytes long in Rust language) into the buffer.
419425 /// It is up to the implementer of [`core::fmt::Write`] to convert the char to a string
420426 /// with proper encoding/charset. For example, in the case of [`alloc::string::String`]
You can’t perform that action at this time.
0 commit comments