4 * Implementation of an ISO-C99 conforming btowc() function; note that,
5 * since this considers only one byte for conversion, and a single byte
6 * can never convert to a surrogate pair, this is not susceptible to the
7 * potential wchar_t overflow error, which may occur with functions such
8 * as mbrtowc(), which may need to return surrogate pairs.
13 * Written by Keith Marshall <keith@users.osdn.me>
14 * Copyright (C) 2020, 2022, MinGW.OSDN Project
17 * Permission is hereby granted, free of charge, to any person obtaining a
18 * copy of this software and associated documentation files (the "Software"),
19 * to deal in the Software without restriction, including without limitation
20 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
21 * and/or sell copies of the Software, and to permit persons to whom the
22 * Software is furnished to do so, subject to the following conditions:
24 * The above copyright notice, this permission notice, and the following
25 * disclaimer shall be included in all copies or substantial portions of
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
29 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
31 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
34 * DEALINGS IN THE SOFTWARE.
39 /* We also need <stdio.h>, for EOF.
44 { /* Implementation of ISO-C99 btowc() function, in libmingwex.a;
45 * this performs an MBCS to wchar_t conversion on the given single
46 * character argument, (expressed as an int), returning WEOF in
47 * the event that conversion fails.
51 (void)(__mingw_mbrtowc_codeset_init());
52 if( __mingw_mbtowc_convert( (char *)(&c), 1, &wc_result, 1) == 1 )
58 /* $RCSfile$: end of file */