ISO/IEC 14957:2010 pdf – Information technology — Representation of data element values — Notation of the format.
1 Scope This International Standard specifies the notation to be used for stating the format, i.e. the character classes, used in the representation of data elements and the length of these representations. It also specifies additional notations relative to the representation of numerical figures. For example, this formatting technique might be used as part of the metadata for data elements. The scope of this International Standard is limited to graphic characters, such as digits, letters and special characters. The scope is limited to the basic datatypes of characters, character strings, integers, reals, and pointers. 2 Normative references The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. ISO/IEC 10646:2003, Information technology — Universal Multiple-Octet Coded Character Set (UCS) 3 Terms and definitions For the purposes of this document, the following terms and definitions apply. 3.1 data element unit of data that is considered, in context, to be indivisible [ISO/IEC 2382-4:1999, 04.07.01] 3.2 character set finite set of characters that is complete for a given purpose [ISO/IEC 2382-4:1999, 04.01.02] 3.3 character type set of characters of the same kind or having the same use EXAMPLE Letters, figures, special characters, etc. 3.4 length length of representation number of characters used to represent a data element
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.