13.3.1 Boolean Values

Boolean format strings lack any special formatting characters. Instead, a boolean format string must have two specifiers (separated by ;). The first specifier is for true values; the second for false values.

When an ASCII string is being converted, it is compared against the format specifiers case insensitive. The following examples show the result of converting a string when the format is yes;no.

Input Result

yes True

Yes True

YES True

no False

No False

NO False

oops Error

y True

n False

In the last two examples, capital letters would have produced the same results. As the last two examples illustrate, it is not necessary to type in all of a boolean value: a partial match is considered valid.

The conversion routines also use a blank as a terminating character. In the example above, input strings of "y s" and "n s" are considered valid and have a value of True and False respectively. The blank stops the conversion process and the value up to the blank is valid.

Boolean values have no standard input rules. If the input string does not match either specifier in a format, it is invalid.