X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=blobdiff_plain;f=functions%2Fwctype%2Ftowlower.c;fp=functions%2Fwctype%2Ftowlower.c;h=7f9809c32af356208ffe5743960a4e448c6f5cbb;hp=0000000000000000000000000000000000000000;hb=b641165a0d122178a33070e3434ab7b49397ad94;hpb=54ea00c95db2e7f49aba027e3f645c99413c415a 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