ISO IEC 14957:2010 pdf download – Information technology — Representation of data element values — Notation of the format
4 Notation relative to character types and length of representation of a data element The format shall be a characterstring sequence. The format is composed of zero or more directives: one or more space characters as defined in ISO/IEC 10646:2003, Clause 20, an ordinary character (neither % nor a space character), or a conversion specification. Each conversion specification is introduced by the character % .
NOTE This specification of formats is based upon the “fscanf()” function in the C programming language (ISO/IEC 9899:1999). Conceptually, the format string implies a syntax processor that consumes syntactic units, as described by the format directives. Because there is no service interface specified by this International Standard, there is no prescribed error handling for strings that do not match the formatting directives.
After the % , the following appear in sequence:
⎯ an optional assignment-suppressing character * ;
⎯ an optional nonzero decimal integer that specifies the maximum field width (in characters);
⎯ an optional length modifier that specifies the size of the receiving object;
⎯ a conversion specifier character that specifies the type of conversion to be applied.
Each directive of the format is processed in turn.
A directive composed of space character(s) is executed by reading input up to the first non-space character (which remains unread), or until no more characters can be read.
A directive that is an ordinary character is executed by reading the next characters of the stream. If any of those characters differ from the ones composing the directive, the directive fails and the differing and subsequent characters remain unread. Similarly, if end-of-file, an encoding error, or a read error prevents a character from being read, the directive fails. A directive that is a conversion specification defines a set of matching input sequences, as described below for each specifier.
A conversion specification is executed in the following steps: Input space characters are skipped, unless the specification includes a [ , c , or n specifier. 1 An input item is read from the stream, unless the specification includes an n specifier. An input item is defined as the longest sequence of input characters which does not exceed any specified field width and which is, or is a prefix of, a matching input sequence. The first character, if any, after the input item remains unread. If the length of the input item is zero, the execution of the directive fails.
This condition is a matching failure unless end-of-file, an encoding error, or a read error prevented input from the stream, in which case it is an input failure. Except in the case of a % specifier, the input item (or, in the case of a %n directive, the count of input characters) is converted to a type appropriate to the conversion specifier. If the input item is not a matching sequence, the execution of the directive fails: this condition is a matching failure.
Unless assignment suppression was indicated by a * , the result of the conversion is placed in the object pointed to by the first argument following the format argument that has not already received a conversion result. If this object does not have an appropriate type, or if the result of the conversion cannot be represented in the object, the behavior is undefined.
The conversion specifiers and their meanings are as follows. ⎯ d matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of the strtol() function with the value 10 for the base argument. Example: “%d” matches “17”, but not “1.0”, “17H”, “ABC”; “%03d” matches “017”, “000”, “017”, but not “1000”. Note: “%d0” will not match any string.
⎯ i matches an optionally signed integer, whose format is the same as expected for the subject sequence of the strtol() function with the value 0 for the base argument. Example: “%i” matches “+17”, “17”, “-17”, but not “1.0”, “+17H”.ISO IEC 14957 pdf download.