1、raising standards worldwide NO COPYING WITHOUT BSI PERMISSION EXCEPT AS PERMITTED BY COPYRIGHT LAW BSI Standards Publication BS ISO/IEC 14957:2010 Information technology Representation of data element values Notation of the formatBS ISO/IEC 14957:2010 BRITISH STANDARD National foreword This British
2、Standard is the UK implementation of ISO/IEC 14957:2010. The UK participation in its preparation was entrusted to Technical Committee IST/40, Data management and interchange. A list of organizations represented on this committee can be obtained on request to its secretary. This publication does not
3、purport to include all the necessary provisions of a contract. Users are responsible for its correct application. BSI 2011 ISBN 978 0 580 61475 0 ICS 35.040 Compliance with a British Standard cannot confer immunity from legal obligations. This British Standard was published under the authority of th
4、e Standards Policy and Strategy Committee on 28 February 2011. Amendments issued since publication Date Text affectedBS ISO/IEC 14957:2010Reference number ISO/IEC 14957:2010(E) ISO/IEC 2010INTERNATIONAL STANDARD ISO/IEC 14957 Second edition 2010-12-15 Information technology Representation of data el
5、ement values Notation of the format Technologies de linformation Reprsentation des valeurs des lments de donnes Notation du format BS ISO/IEC 14957:2010 ISO/IEC 14957:2010(E) PDF disclaimer This PDF file may contain embedded typefaces. In accordance with Adobes licensing policy, this file may be pri
6、nted or viewed but shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this file, parties accept therein the responsibility of not infringing Adobes licensing policy. The ISO Central Secretariat accepts no l
7、iability in this area. Adobe is a trademark of Adobe Systems Incorporated. Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation parameters were optimized for printing. Every care has been taken to ensure that the file i
8、s suitable for use by ISO member bodies. In the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below. COPYRIGHT PROTECTED DOCUMENT ISO/IEC 2010 All rights reserved. Unless otherwise specified, no part of this publication may be repro
9、duced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISOs member body in the country of the requester. ISO copyright office Case postale 56 CH-1211 Geneva 20 Tel. + 41 22 7
10、49 01 11 Fax + 41 22 749 09 47 E-mail copyrightiso.org Web www.iso.org Published in Switzerland ii ISO/IEC 2010 All rights reservedBS ISO/IEC 14957:2010 ISO/IEC 14957:2010(E) ISO/IEC 2010 All rights reserved iiiForeword ISO (the International Organization for Standardization) and IEC (the Internatio
11、nal Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields
12、of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a join
13、t technical committee, ISO/IEC JTC 1. International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2. The main task of the joint technical committee is to prepare International Standards. Draft International Standards adopted by the joint technical committee
14、 are circulated to national bodies for voting. Publication as an International Standard requires approval by at least 75 % of the national bodies casting a vote. Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall no
15、t be held responsible for identifying any or all such patent rights. ISO/IEC 14957 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 32, Data management and interchange. This second edition cancels and replaces the first edition (ISO/IEC 14957:1996), wh
16、ich has been technically revised. BS ISO/IEC 14957:2010 ISO/IEC 14957:2010(E) iv ISO/IEC 2010 All rights reservedIntroduction Data interchange is experiencing rapid expansion in the commercial, technical and public sectors. It gives rise to interworking between different communities which have often
17、 independently developed information processing applications and telecommunication networks to meet specific needs. Hence, the overall situation suffers from a lack of homogeneity. In order to remedy this situation, an urgent standardization effort focused in particular on the representation of data
18、 elements is necessary. The representation of a data element supposes in the first place that the format, i.e. the types of character used in the representation and the length of the representation, is specified. In order that these specifications have the same significance for everyone involved, it
19、 is necessary to express them in accordance with standardized conventions. Such rules are likely to eliminate any and all risk of ambiguity, lack of understanding and error; they also facilitate the comparison of data element dictionaries, the design and creation of information systems, and electron
20、ic data interchange (EDI). These notations have been partially and variously expressed in different International Standards according to the specific contexts in which they have been defined, e.g. EDIFACT (ISO 9735), banking standards (such as ISO 7982-1), character sets (ISO/IEC 8859), information
21、processing (ISO 6093), and programming languages (ISO/IEC 9899). The objective of this International Standard is to provide a unique source of reference on this subject for all standards utilizing these type of notations independently of their environments. BS ISO/IEC 14957:2010 INTERNATIONAL STANDA
22、RD ISO/IEC 14957:2010(E) ISO/IEC 2010 All rights reserved 1Information 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
23、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
24、 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 refere
25、nces, 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
26、 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
27、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 BS ISO/IEC 14957:2010 ISO/IEC 14957:2010(E) 2 ISO/IEC 2010 All rights reserved4 Notation relative to character types and l
28、ength 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 specificatio
29、n. 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
30、 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 optiona
31、l 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 di
32、rective 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 diff
33、er 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 s
34、et 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. 1An input item is read from the stream, unless the specification includes
35、 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,
36、 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
37、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
38、 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. 1 These space characters
39、are not counted against a specified field width. BS ISO/IEC 14957:2010 ISO/IEC 14957:2010(E) ISO/IEC 2010 All rights reserved 3The 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
40、 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 sub
41、ject sequence of the strtol() function with the value 0 for the base argument. Example: “%i“ matches “+17“, “17“, “-17“, but not “1.0“, “+17H“. o matches an optionally signed octal integer, whose format is the same as expected for the subject sequence of the strtoul() function with the value 8 for t
42、he base argument. Example: “%o“ matches “0123“, “-456“, but not “0789“. u matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of the strtoul() function with the value 10 for the base argument. Example: “%u“ matches “17“, but not “+17“, “-17“. x
43、 matches an optionally signed hexadecimal integer, whose format is the same as expected for the subject sequence of the strtoul() function with the value 16 for the base argument. Example: “%x“ matches “013EF“, “-013ef“, but not “013EFG“. a,e,f,g match 2an optionally signed floating-point number, in
44、finity, or NaN, whose format is the same as expected for the subject sequence of the strtod() function. The corresponding argument shall be a pointer to floating. Example: “%f“ matches “1.2E10“, “+1.2E+10“, “-1.2e-10“, “infinity, “nan“ but not “1.2F10“, “nan“. c matches a sequence of characters of e
45、xactly the number specified by the field width (1 if no field width is present in the directive). If length modifier is present, the input shall be a sequence of characters. Examples: “%c“ matches “X“ but not “XY“; “%2c“ matches “XY“. s matches a sequence of non-space characters. If length modifier
46、is present, the input shall be a sequence of characters. Examples: “%s“ matches “123abc“, “123abcd“, “ but not “123 abc“. matches a nonempty sequence of characters from a set of expected characters (the scanset). The conversion specifier includes all subsequent characters in the format string, up to
47、 and including the matching right bracket (). The characters between the brackets (the scanlist) compose the scanset, unless the character after the left bracket is a circumflex (), in which case the scanset contains all characters that do not appear in the scanlist between the circumflex and the ri
48、ght bracket. If the conversion specifier begins with or , the right bracket character is in the scanlist and the next following right bracket character is the matching right bracket that ends the specification; otherwise the first following right bracket character is the one that ends the specificat
49、ion. If a - character is in the scanlist and is not the first, nor the second where the first character is a , nor the last character, the behavior is implementation-defined. Examples: “abcad-f“ matches “abca“, “abcd“, “abce“, “abcf“, but not “abc“, “abcg“; “abcd-f“ matches “abcg“ but not “abc“, “abcd“. % matches a single % character; no conversion occurs. The complete conversion specification shall be %. 2 There is no distinction among a, e, f, and g formats. BS ISO/IEC 14957:2010 ISO