From: Owen Shepherd Date: Sat, 16 Mar 2013 20:27:34 +0000 (+0000) Subject: PDCLIB-3 towupper(3) towlower(3) X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=75bf0c22663cec60d8164c8cf77e855a8b6ad459 PDCLIB-3 towupper(3) towlower(3) --- 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 diff --git a/functions/wctype/towupper.c b/functions/wctype/towupper.c new file mode 100644 index 0000000..faac657 --- /dev/null +++ b/functions/wctype/towupper.c @@ -0,0 +1,36 @@ +/* towupper( 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 towupper( wint_t wc ) +{ + wint_t uwc = _PDCLIB_unpackwint( wc ); + _PDCLIB_wcinfo_t *info = _PDCLIB_wcgetinfo( uwc ); + if( info && info->upper != uwc ) + { + wc = info->upper; + } + return wc; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(towupper(0) == 0); + TESTCASE(towupper(L'a') == L'A'); + TESTCASE(towupper(L'B') == L'B'); + TESTCASE(towupper(L'0') == L'0'); + + return TEST_RESULTS; +} +#endif