Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB

  1. /***
  2. *towlower.c - convert wide character to lower case
  3. *
  4. * Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines towlower().
  8. *
  9. *Revision History:
  10. * 10-11-91 ETC Created.
  11. * 12-10-91 ETC Updated nlsapi; added multithread.
  12. * 04-06-92 KRS Make work without _INTL also.
  13. * 01-19-93 CFW Changed LCMapString to LCMapStringW.
  14. * 06-02-93 SRW ignore _INTL if _NTSUBSET_ defined.
  15. * 06-11-93 CFW Fix error handling bug.
  16. *
  17. *******************************************************************************/
  18. #include <windows.h>
  19. #include <cruntime.h>
  20. /***
  21. *wchar_t towlower(c) - convert wide character to lower case
  22. *
  23. *Purpose:
  24. * towlower() returns the lowercase equivalent of its argument
  25. *
  26. *Entry:
  27. * c - wchar_t value of character to be converted
  28. *
  29. *Exit:
  30. * if c is an upper case letter, returns wchar_t value of lower case
  31. * representation of c. otherwise, it returns c.
  32. *
  33. *Exceptions:
  34. *
  35. *******************************************************************************/
  36. wchar_t _CALLTYPE1 towlower (
  37. wchar_t c
  38. )
  39. {
  40. // If we're in the first 128 characters, it's just ANSII...
  41. if (c < 128) {
  42. return (wchar_t)CharLowerA((LPSTR)c);
  43. } else {
  44. WCHAR wBuffer[2];
  45. CHAR Buffer[8];
  46. int Length;
  47. BOOL fDefaultChar;
  48. wBuffer[0] = c;
  49. Length = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wBuffer, 1, Buffer, sizeof (Buffer), NULL, &fDefaultChar);
  50. if (fDefaultChar == FALSE)
  51. {
  52. Buffer[Length] = '\0';
  53. CharLowerA (Buffer);
  54. MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, Buffer, Length, wBuffer, 1);
  55. }
  56. return wBuffer[0];
  57. }
  58. }