Leaked source code of windows server 2003
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.

64 lines
1.1 KiB

  1. #include "globals.h"
  2. #include <ctype.h>
  3. //
  4. // Convert wszBuf to upper case in-place (ie, modify the existing string).
  5. //
  6. void
  7. ToUpper( WCHAR *wszBuf )
  8. {
  9. //
  10. // Param check. strlen crashes when you pass it NULL, so the assumption
  11. // is that wcslen does also.
  12. //
  13. if( NULL == wszBuf )
  14. {
  15. return;
  16. }
  17. const int iLen = wcslen( wszBuf );
  18. //
  19. // For each character that needs to be converted to upper case, do
  20. // the conversion in-place.
  21. //
  22. for( int i = 0; i < iLen; i++ )
  23. {
  24. if( iswlower( wszBuf[ i ] ) )
  25. {
  26. wszBuf[ i ] = towupper( wszBuf[ i ] );
  27. }
  28. }
  29. }
  30. //
  31. // Convert wszBuf to lower case in-place (ie, modify the existing string).
  32. //
  33. void
  34. ToLower( WCHAR *wszBuf )
  35. {
  36. //
  37. // Param check. strlen crashes when you pass it NULL, so the assumption
  38. // is that wcslen does also.
  39. //
  40. if( NULL == wszBuf )
  41. {
  42. return;
  43. }
  44. const int iLen = wcslen( wszBuf );
  45. //
  46. // For each character that needs to be converted to upper case, do
  47. // the conversion in-place.
  48. //
  49. for( int i = 0; i < iLen; i++ )
  50. {
  51. if( iswupper( wszBuf[ i ] ) )
  52. {
  53. wszBuf[ i ] = towlower( wszBuf[ i ] );
  54. }
  55. }
  56. }