X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fwctype%2Ftowlower.c;fp=functions%2Fwctype%2Ftowlower.c;h=7f9809c32af356208ffe5743960a4e448c6f5cbb;hb=75bf0c22663cec60d8164c8cf77e855a8b6ad459;hp=0000000000000000000000000000000000000000;hpb=495dc4306cf5b9437faa86b8c7a6eaeaa51ee83a;p=pdclib diff --git a/functions/wctype/towlower.c b/functions/wctype/towlower.c new file mode 100644 index 0000000..7f9809c --- /dev/null +++ b/functions/wctype/towlower.c @@ -0,0 +1,36 @@ +/* towlower( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +wint_t towlower( wint_t wc ) +{ + wint_t uwc = _PDCLIB_unpackwint( wc ); + _PDCLIB_wcinfo_t *info = _PDCLIB_wcgetinfo( uwc ); + if( info && info->lower != uwc ) + { + wc = info->lower; + } + return wc; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(towlower(0) == 0); + TESTCASE(towlower(L'a') == L'a'); + TESTCASE(towlower(L'B') == L'b'); + TESTCASE(towlower(L'0') == L'0'); + + return TEST_RESULTS; +} +#endif