Updated and synchronized documentation comments for QrSegment's constants/functions involving character sets, in all languages.
This commit is contained in:
parent
aa39108f0d
commit
85eb6493fd
|
@ -86,7 +86,8 @@ static int numCharCountBits(enum qrcodegen_Mode mode, int version);
|
|||
|
||||
/*---- Private tables of constants ----*/
|
||||
|
||||
// For checking text and encoding segments.
|
||||
// The set of all legal characters in alphanumeric mode, where each character
|
||||
// value maps to the index in the string. For checking text and encoding segments.
|
||||
static const char *ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
||||
|
||||
// For generating error correction codes.
|
||||
|
|
|
@ -172,12 +172,15 @@ bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcod
|
|||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
bool qrcodegen_isAlphanumeric(const char *text);
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
bool qrcodegen_isNumeric(const char *text);
|
||||
|
||||
|
|
|
@ -126,12 +126,15 @@ class QrSegment final {
|
|||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
public: static bool isAlphanumeric(const char *text);
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
public: static bool isNumeric(const char *text);
|
||||
|
||||
|
@ -198,7 +201,8 @@ class QrSegment final {
|
|||
|
||||
/*---- Private constant ----*/
|
||||
|
||||
/* The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string. */
|
||||
/* The set of all legal characters in alphanumeric mode, where
|
||||
* each character value maps to the index in the string. */
|
||||
private: static const char *ALPHANUMERIC_CHARSET;
|
||||
|
||||
};
|
||||
|
|
|
@ -222,13 +222,19 @@ public final class QrSegment {
|
|||
|
||||
/*---- Constants ----*/
|
||||
|
||||
/** Can test whether a string is encodable in numeric mode (such as by using {@link #makeNumeric(String)}). */
|
||||
/** Describes precisely all strings that are encodable in numeric mode. To test whether a
|
||||
* string {@code s} is encodable: {@code boolean ok = NUMERIC_REGEX.matcher(s).matches();}.
|
||||
* A string is encodable iff each character is in the range 0 to 9. */
|
||||
public static final Pattern NUMERIC_REGEX = Pattern.compile("[0-9]*");
|
||||
|
||||
/** Can test whether a string is encodable in alphanumeric mode (such as by using {@link #makeAlphanumeric(String)}). */
|
||||
/** Describes precisely all strings that are encodable in alphanumeric mode. To test whether a
|
||||
* string {@code s} is encodable: {@code boolean ok = ALPHANUMERIC_REGEX.matcher(s).matches();}.
|
||||
* 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. */
|
||||
public static final Pattern ALPHANUMERIC_REGEX = Pattern.compile("[A-Z0-9 $%*+./:-]*");
|
||||
|
||||
/** The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string. */
|
||||
/** The set of all legal characters in alphanumeric mode, where
|
||||
* each character value maps to the index in the string. */
|
||||
static final String ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
||||
|
||||
|
||||
|
|
|
@ -834,13 +834,19 @@ var qrcodegen = new function() {
|
|||
|
||||
var QrSegment = {}; // Private object to assign properties to. Not the same object as 'this.QrSegment'.
|
||||
|
||||
// (Public) Can test whether a string is encodable in numeric mode (such as by using QrSegment.makeNumeric()).
|
||||
// (Public) Describes precisely all strings that are encodable in numeric mode.
|
||||
// To test whether a string s is encodable: var ok = NUMERIC_REGEX.test(s);
|
||||
// A string is encodable iff each character is in the range 0 to 9.
|
||||
this.QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
|
||||
|
||||
// (Public) Can test whether a string is encodable in alphanumeric mode (such as by using QrSegment.makeAlphanumeric()).
|
||||
// (Public) Describes precisely all strings that are encodable in alphanumeric mode.
|
||||
// To test whether a string s is encodable: var ok = ALPHANUMERIC_REGEX.test(s);
|
||||
// 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.
|
||||
this.QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
|
||||
|
||||
// (Private) The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string.
|
||||
// (Private) The set of all legal characters in alphanumeric mode,
|
||||
// where each character value maps to the index in the string.
|
||||
QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
||||
|
||||
|
||||
|
|
|
@ -733,10 +733,16 @@ class QrSegment(object):
|
|||
|
||||
# ---- Constants ----
|
||||
|
||||
# (Public) Can test whether a string is encodable in numeric mode (such as by using make_numeric())
|
||||
# (Public) Describes precisely all strings that are encodable in numeric mode.
|
||||
# To test whether a string s is encodable: ok = NUMERIC_REGEX.fullmatch(s) is not None
|
||||
# A string is encodable iff each character is in the range 0 to 9.
|
||||
NUMERIC_REGEX = re.compile(r"[0-9]*\Z")
|
||||
|
||||
# (Public) Can test whether a string is encodable in alphanumeric mode (such as by using make_alphanumeric())
|
||||
# (Public) Describes precisely all strings that are encodable in alphanumeric mode.
|
||||
# To test whether a string s is encodable: ok = ALPHANUMERIC_REGEX.fullmatch(s) is not None
|
||||
# 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.
|
||||
|
||||
ALPHANUMERIC_REGEX = re.compile(r"[A-Z0-9 $%*+./:-]*\Z")
|
||||
|
||||
# (Private) Dictionary of "0"->0, "A"->10, "$"->37, etc.
|
||||
|
|
|
@ -1002,12 +1002,15 @@ impl QrSegment {
|
|||
|
||||
|
||||
// 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 {
|
||||
text.iter().all(|c| ALPHANUMERIC_CHARSET.contains(c))
|
||||
}
|
||||
|
||||
|
||||
// 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 {
|
||||
text.iter().all(|c| '0' <= *c && *c <= '9')
|
||||
}
|
||||
|
|
|
@ -799,13 +799,19 @@ namespace qrcodegen {
|
|||
|
||||
/*-- Constants --*/
|
||||
|
||||
// Can test whether a string is encodable in numeric mode (such as by using QrSegment.makeNumeric()).
|
||||
// Describes precisely all strings that are encodable in numeric mode. To test
|
||||
// whether a string s is encodable: let ok: boolean = NUMERIC_REGEX.test(s);
|
||||
// A string is encodable iff each character is in the range 0 to 9.
|
||||
public static readonly NUMERIC_REGEX: RegExp = /^[0-9]*$/;
|
||||
|
||||
// Can test whether a string is encodable in alphanumeric mode (such as by using QrSegment.makeAlphanumeric()).
|
||||
// Describes precisely all strings that are encodable in alphanumeric mode. To test
|
||||
// whether a string s is encodable: let ok: boolean = ALPHANUMERIC_REGEX.test(s);
|
||||
// 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.
|
||||
public static readonly ALPHANUMERIC_REGEX: RegExp = /^[A-Z0-9 $%*+.\/:-]*$/;
|
||||
|
||||
// The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string.
|
||||
// The set of all legal characters in alphanumeric mode,
|
||||
// where each character value maps to the index in the string.
|
||||
private static readonly ALPHANUMERIC_CHARSET: string = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue