File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ impl Char16 {
83
83
pub const unsafe fn from_u16_unchecked ( val : u16 ) -> Self {
84
84
Self ( val)
85
85
}
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
+ }
86
92
}
87
93
88
94
impl TryFrom < char > for Char16 {
Original file line number Diff line number Diff line change @@ -415,6 +415,12 @@ impl CStr16 {
415
415
self . 0 . len ( ) * 2
416
416
}
417
417
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
+
418
424
/// Writes each [`Char16`] as a [`char`] (4 bytes long in Rust language) into the buffer.
419
425
/// It is up to the implementer of [`core::fmt::Write`] to convert the char to a string
420
426
/// 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