Стандарт языка Си С99 TC (1113411), страница 64
Текст из файла (страница 64)
If the alternative format orspecification does not exist for the current locale, the modifier is ignored.%Ec is replaced by the locale’s alternative date and time representation.%EC is replaced by the name of the base year (period) in the locale’s alternativerepresentation.%Ex is replaced by the locale’s alternative date representation.%EX is replaced by the locale’s alternative time representation.%Ey is replaced by the offset from %EC (year only) in the locale’s alternativerepresentation.%EY is replaced by the locale’s full alternative year representation.%Od is replaced by the day of the month, using the locale’s alternative numeric symbols(filled as needed with leading zeros, or with leading spaces if there is no alternativesymbol for zero).%Oe is replaced by the day of the month, using the locale’s alternative numeric symbols(filled as needed with leading spaces).%OH is replaced by the hour (24-hour clock), using the locale’s alternative numericsymbols.§7.23.3.5Library345ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256%OI is replaced by the hour (12-hour clock), using the locale’s alternative numericsymbols.%Om is replaced by the month, using the locale’s alternative numeric symbols.%OM is replaced by the minutes, using the locale’s alternative numeric symbols.%OS is replaced by the seconds, using the locale’s alternative numeric symbols.%Ou is replaced by the ISO 8601 weekday as a number in the locale’s alternativerepresentation, where Monday is 1.%OU is replaced by the week number, using the locale’s alternative numeric symbols.%OV is replaced by the ISO 8601 week number, using the locale’s alternative numericsymbols.%Ow is replaced by the weekday as a number, using the locale’s alternative numericsymbols.%OW is replaced by the week number of the year, using the locale’s alternative numericsymbols.%Oy is replaced by the last 2 digits of the year, using the locale’s alternative numericsymbols.5%g, %G, and %V give values according to the ISO 8601 week-based year.
In this system,weeks begin on a Monday and week 1 of the year is the week that includes January 4th,which is also the week that includes the first Thursday of the year, and is also the firstweek that contains at least four days in the year.
If the first Monday of January is the2nd, 3rd, or 4th, the preceding days are part of the last week of the preceding year; thus,for Saturday 2nd January 1999, %G is replaced by 1998 and %V is replaced by 53. IfDecember 29th, 30th, or 31st is a Monday, it and any following days are part of week 1 ofthe following year. Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and%V is replaced by 01.6If a conversion specifier is not one of the above, the behavior is undefined.7In the "C" locale, the E and O modifiers are ignored and the replacement strings for thefollowing specifiers are:%a%A%b%B%c%p%r%x%X%Z346the first three characters of %A.one of ‘‘Sunday’’, ‘‘Monday’’, ...
, ‘‘Saturday’’.the first three characters of %B.one of ‘‘January’’, ‘‘February’’, ... , ‘‘December’’.equivalent to ‘‘%a %b %e %T %Y’’.one of ‘‘AM’’ or ‘‘PM’’.equivalent to ‘‘%I:%M:%S %p’’.equivalent to ‘‘%m/%d/%y’’.equivalent to %T.implementation-defined.Library§7.23.3.5WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3Returns8If the total number of resulting characters including the terminating null character is notmore than maxsize, the strftime function returns the number of characters placedinto the array pointed to by s not including the terminating null character. Otherwise,zero is returned and the contents of the array are indeterminate.§7.23.3.5Library347ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.24 Extended multibyte and wide character utilities <wchar.h>7.24.1 Introduction1The header <wchar.h> declares four data types, one tag, four macros, and manyfunctions.277)2The types declared are wchar_t and size_t (both described in 7.17);mbstate_twhich is an object type other than an array type that can hold the conversion stateinformation necessary to convert between sequences of multibyte characters and widecharacters;wint_twhich is an integer type unchanged by default argument promotions that can hold anyvalue corresponding to members of the extended character set, as well as at least onevalue that does not correspond to any member of the extended character set (see WEOFbelow);278) andstruct tmwhich is declared as an incomplete structure type (the contents are described in 7.23.1).3The macros defined are NULL (described in 7.17); WCHAR_MIN and WCHAR_MAX(described in 7.18.3); andWEOFwhich expands to a constant expression of type wint_t whose value does notcorrespond to any member of the extended character set.279) It is accepted (and returned)by several functions in this subclause to indicate end-of-file, that is, no more input from astream.
It is also used as a wide character value that does not correspond to any memberof the extended character set.4The functions declared are grouped as follows:— Functions that perform input and output of wide characters, or multibyte characters,or both;— Functions that provide wide string numeric conversion;— Functions that perform general wide string manipulation;277) See ‘‘future library directions’’ (7.26.12).278) wchar_t and wint_t can be the same integer type.279) The value of the macro WEOF may differ from that of EOF and need not be negative.348Library§7.24.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3— Functions for wide string date and time conversion; and— Functions that provide extended capabilities for conversion between multibyte andwide character sequences.5Unless explicitly stated otherwise, if the execution of a function described in thissubclause causes copying to take place between objects that overlap, the behavior isundefined.7.24.2 Formatted wide character input/output functions1The formatted wide character input/output functions shall behave as if there is a sequencepoint after the actions associated with each specifier.280)7.24.2.1 The fwprintf functionSynopsis1#include <stdio.h>#include <wchar.h>int fwprintf(FILE * restrict stream,const wchar_t * restrict format, ...);Description2The fwprintf function writes output to the stream pointed to by stream, undercontrol of the wide string pointed to by format that specifies how subsequent argumentsare converted for output.
If there are insufficient arguments for the format, the behavioris undefined. If the format is exhausted while arguments remain, the excess argumentsare evaluated (as always) but are otherwise ignored. The fwprintf function returnswhen the end of the format string is encountered.3The format is composed of zero or more directives: ordinary wide characters (not %),which are copied unchanged to the output stream; and conversion specifications, each ofwhich results in fetching zero or more subsequent arguments, converting them, ifapplicable, according to the corresponding conversion specifier, and then writing theresult to the output stream.4Each conversion specification is introduced by the wide character %.
After the %, thefollowing appear in sequence:— Zero or more flags (in any order) that modify the meaning of the conversionspecification.— An optional minimum field width. If the converted value has fewer wide charactersthan the field width, it is padded with spaces (by default) on the left (or right, if the280) The fwprintf functions perform writes to memory for the %n specifier.§7.24.2.1Library349ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256left adjustment flag, described later, has been given) to the field width. The fieldwidth takes the form of an asterisk * (described later) or a nonnegative decimalinteger.281)— An optional precision that gives the minimum number of digits to appear for the d, i,o, u, x, and X conversions, the number of digits to appear after the decimal-pointwide character for a, A, e, E, f, and F conversions, the maximum number ofsignificant digits for the g and G conversions, or the maximum number of widecharacters to be written for s conversions.
The precision takes the form of a period(.) followed either by an asterisk * (described later) or by an optional decimalinteger; if only the period is specified, the precision is taken as zero. If a precisionappears with any other conversion specifier, the behavior is undefined.— An optional length modifier that specifies the size of the argument.— A conversion specifier wide character that specifies the type of conversion to beapplied.5As noted above, a field width, or precision, or both, may be indicated by an asterisk. Inthis case, an int argument supplies the field width or precision. The argumentsspecifying field width, or precision, or both, shall appear (in that order) before theargument (if any) to be converted.
A negative field width argument is taken as a - flagfollowed by a positive field width. A negative precision argument is taken as if theprecision were omitted.6The flag wide characters and their meanings are:-The result of the conversion is left-justified within the field. (It is right-justified ifthis flag is not specified.)+The result of a signed conversion always begins with a plus or minus sign. (Itbegins with a sign only when a negative value is converted if this flag is notspecified.)282)space If the first wide character of a signed conversion is not a sign, or if a signedconversion results in no wide characters, a space is prefixed to the result.