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.

67 lines
1.7 KiB

  1. /***
  2. *towupper.c - convert wide character to upper case
  3. *
  4. * Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines towupper().
  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. * 01-14-94 SRW if _NTSUBSET_ defined call Rtl functions
  17. # 11-14-95 JAE Use Win32 function
  18. *
  19. *******************************************************************************/
  20. #include <windows.h>
  21. #include <cruntime.h>
  22. /***
  23. *wchar_t towupper(c) - convert wide character to upper case
  24. *
  25. *Purpose:
  26. * towupper() returns the uppercase equivalent of its argument
  27. *
  28. *Entry:
  29. * c - wchar_t value of character to be converted
  30. *
  31. *Exit:
  32. * if c is a lower case letter, returns wchar_t value of upper case
  33. * representation of c. otherwise, it returns c.
  34. *
  35. *Exceptions:
  36. *
  37. *******************************************************************************/
  38. wchar_t _CALLTYPE1 towupper (
  39. wchar_t c
  40. )
  41. {
  42. // If we're in the first 128 characters, it's just ANSII...
  43. if (c < 128) {
  44. return (wchar_t)CharUpperA((LPSTR)c);
  45. } else {
  46. WCHAR wBuffer[2];
  47. CHAR Buffer[8];
  48. int Length;
  49. BOOL fDefaultChar;
  50. wBuffer[0] = c;
  51. Length = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wBuffer, 1, Buffer, sizeof (Buffer), NULL, &fDefaultChar);
  52. if (fDefaultChar == FALSE)
  53. {
  54. Buffer[Length] = '\0';
  55. CharUpperA (Buffer);
  56. MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, Buffer, Length, wBuffer, 1);
  57. }
  58. return wBuffer[0];
  59. }
  60. }