Стандарт языка Си С99 TC (1113411), страница 69
Текст из файла (страница 69)
If the file cannotsupport positioning requests, or if the stream was opened with append mode, thecharacter is appended to the output stream.Returns3The fputwc function returns the wide character written. If a write error occurs, theerror indicator for the stream is set and fputwc returns WEOF. If an encoding erroroccurs, the value of the macro EILSEQ is stored in errno and fputwc returns WEOF.7.24.3.4 The fputws functionSynopsis1#include <stdio.h>#include <wchar.h>int fputws(const wchar_t * restrict s,FILE * restrict stream);Description2The fputws function writes the wide string pointed to by s to the stream pointed to bystream. The terminating null wide character is not written.Returns3The fputws function returns EOF if a write or encoding error occurs; otherwise, itreturns a nonnegative value.368Library§7.24.3.4WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.3.5 The fwide functionSynopsis1#include <stdio.h>#include <wchar.h>int fwide(FILE *stream, int mode);Description2The fwide function determines the orientation of the stream pointed to by stream.
Ifmode is greater than zero, the function first attempts to make the stream wide oriented. Ifmode is less than zero, the function first attempts to make the stream byte oriented.293)Otherwise, mode is zero and the function does not alter the orientation of the stream.Returns3The fwide function returns a value greater than zero if, after the call, the stream haswide orientation, a value less than zero if the stream has byte orientation, or zero if thestream has no orientation.7.24.3.6 The getwc functionSynopsis1#include <stdio.h>#include <wchar.h>wint_t getwc(FILE *stream);Description2The getwc function is equivalent to fgetwc, except that if it is implemented as amacro, it may evaluate stream more than once, so the argument should never be anexpression with side effects.Returns3The getwc function returns the next wide character from the input stream pointed to bystream, or WEOF.7.24.3.7 The getwchar functionSynopsis1#include <wchar.h>wint_t getwchar(void);293) If the orientation of the stream has already been determined, fwide does not change it.§7.24.3.7Library369ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256Description2The getwchar function is equivalent to getwc with the argument stdin.Returns3The getwchar function returns the next wide character from the input stream pointed toby stdin, or WEOF.7.24.3.8 The putwc functionSynopsis1#include <stdio.h>#include <wchar.h>wint_t putwc(wchar_t c, FILE *stream);Description2The putwc function is equivalent to fputwc, except that if it is implemented as amacro, it may evaluate stream more than once, so that argument should never be anexpression with side effects.Returns3The putwc function returns the wide character written, or WEOF.7.24.3.9 The putwchar functionSynopsis1#include <wchar.h>wint_t putwchar(wchar_t c);Description2The putwchar function is equivalent to putwc with the second argument stdout.Returns3The putwchar function returns the character written, or WEOF.7.24.3.10 The ungetwc functionSynopsis1#include <stdio.h>#include <wchar.h>wint_t ungetwc(wint_t c, FILE *stream);Description2The ungetwc function pushes the wide character specified by c back onto the inputstream pointed to by stream.
Pushed-back wide characters will be returned bysubsequent reads on that stream in the reverse order of their pushing. A successful370Library§7.24.3.10WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3intervening call (with the stream pointed to by stream) to a file positioning function(fseek, fsetpos, or rewind) discards any pushed-back wide characters for thestream. The external storage corresponding to the stream is unchanged.3One wide character of pushback is guaranteed, even if the call to the ungetwc functionfollows just after a call to a formatted wide character input function fwscanf,vfwscanf, vwscanf, or wscanf. If the ungetwc function is called too many timeson the same stream without an intervening read or file positioning operation on thatstream, the operation may fail.4If the value of c equals that of the macro WEOF, the operation fails and the input stream isunchanged.5A successful call to the ungetwc function clears the end-of-file indicator for the stream.The value of the file position indicator for the stream after reading or discarding allpushed-back wide characters is the same as it was before the wide characters were pushedback.
For a text or binary stream, the value of its file position indicator after a successfulcall to the ungetwc function is unspecified until all pushed-back wide characters areread or discarded.Returns6The ungetwc function returns the wide character pushed back, or WEOF if the operationfails.7.24.4 General wide string utilities1The header <wchar.h> declares a number of functions useful for wide stringmanipulation. Various methods are used for determining the lengths of the arrays, but inall cases a wchar_t * argument points to the initial (lowest addressed) element of thearray. If an array is accessed beyond the end of an object, the behavior is undefined.2Where an argument declared as size_t n determines the length of the array for afunction, n can have the value zero on a call to that function.
Unless explicitly statedotherwise in the description of a particular function in this subclause, pointer argumentson such a call shall still have valid values, as described in 7.1.4. On such a call, afunction that locates a wide character finds no occurrence, a function that compares twowide character sequences returns zero, and a function that copies wide characters copieszero wide characters.§7.24.4Library371ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.24.4.1 Wide string numeric conversion functions7.24.4.1.1 The wcstod, wcstof, and wcstold functionsSynopsis1#include <wchar.h>double wcstod(const wchar_t * restrict nptr,wchar_t ** restrict endptr);float wcstof(const wchar_t * restrict nptr,wchar_t ** restrict endptr);long double wcstold(const wchar_t * restrict nptr,wchar_t ** restrict endptr);Description2The wcstod, wcstof, and wcstold functions convert the initial portion of the widestring pointed to by nptr to double, float, and long double representation,respectively.
First, they decompose the input string into three parts: an initial, possiblyempty, sequence of white-space wide characters (as specified by the iswspacefunction), a subject sequence resembling a floating-point constant or representing aninfinity or NaN; and a final wide string of one or more unrecognized wide characters,including the terminating null wide character of the input wide string. Then, they attemptto convert the subject sequence to a floating-point number, and return the result.3The expected form of the subject sequence is an optional plus or minus sign, then one ofthe following:— a nonempty sequence of decimal digits optionally containing a decimal-point widecharacter, then an optional exponent part as defined for the corresponding single-bytecharacters in 6.4.4.2;— a 0x or 0X, then a nonempty sequence of hexadecimal digits optionally containing adecimal-point wide character, then an optional binary exponent part as defined in6.4.4.2;— INF or INFINITY, or any other wide string equivalent except for case— NAN or NAN(n-wchar-sequenceopt), or any other wide string equivalent except forcase in the NAN part, where:n-wchar-sequence:digitnondigitn-wchar-sequence digitn-wchar-sequence nondigitThe subject sequence is defined as the longest initial subsequence of the input widestring, starting with the first non-white-space wide character, that is of the expected form.372Library§7.24.4.1.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3The subject sequence contains no wide characters if the input wide string is not of theexpected form.4If the subject sequence has the expected form for a floating-point number, the sequence ofwide characters starting with the first digit or the decimal-point wide character(whichever occurs first) is interpreted as a floating constant according to the rules of6.4.4.2, except that the decimal-point wide character is used in place of a period, and thatif neither an exponent part nor a decimal-point wide character appears in a decimalfloating point number, or if a binary exponent part does not appear in a hexadecimalfloating point number, an exponent part of the appropriate type with value zero isassumed to follow the last digit in the string.