1 // 2 // wctrans.cpp 3 // 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // 6 // Implementations of the towctrans and wctrans functions. 7 // 8 #include <corecrt.h> 9 #include <ctype.h> 10 #include <string.h> 11 #include <wctype.h> 12 13 #pragma warning(disable:4244) 14 15 16 17 typedef wchar_t wctrans_t; 18 19 static struct wctab 20 { 21 char const* s; 22 wctype_t value; 23 } 24 const tab[] = 25 { 26 { "tolower", 2 }, 27 { "toupper", 1 }, 28 { nullptr, 0 } 29 }; 30 31 32 33 extern "C" wint_t __cdecl towctrans(wint_t const c, wctrans_t const value) 34 { 35 return value == 1 ? towupper(c) : towlower(c); 36 } 37 38 extern "C" wctrans_t __cdecl wctrans(char const* const name) 39 { 40 for (unsigned n = 0; tab[n].s != 0; ++n) 41 { 42 if (strcmp(tab[n].s, name) == 0) 43 return tab[n].value; 44 } 45 46 return 0; 47 } 48 49 /* 50 * Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED. 51 * Consult your license regarding permissions and restrictions. 52 V5.03:0009 */ 53