Publicized the Rust functions QrSegment.{is_numeric(),is_alphanumeric()}.

pull/118/head
Project Nayuki 3 years ago
parent 0e80f23c04
commit fd425bf995

@ -1116,17 +1116,19 @@ impl QrSegment {
}
// Tests whether the given string can be encoded as a segment in numeric mode.
// A string is encodable iff each character is in the range 0 to 9.
fn is_numeric(text: &[char]) -> bool {
/// Tests whether the given string can be encoded as a segment in numeric mode.
///
/// A string is encodable iff each character is in the range 0 to 9.
pub fn is_numeric(text: &[char]) -> bool {
text.iter().all(|&c| '0' <= c && c <= '9')
}
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
fn is_alphanumeric(text: &[char]) -> bool {
/// Tests whether the given string can be encoded as a segment in alphanumeric mode.
///
/// A string is encodable iff each character is in the following set: 0 to 9, A to Z
/// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
pub fn is_alphanumeric(text: &[char]) -> bool {
text.iter().all(|c| ALPHANUMERIC_CHARSET.contains(c))
}

Loading…
Cancel
Save