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.

49 lines
1.1 KiB

  1. /***
  2. *wtox.c - _wtoi and _wtol conversion
  3. *
  4. * Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Converts a wide character string into an int or long.
  8. *
  9. *******************************************************************************/
  10. #include <windows.h>
  11. #include <stdlib.h>
  12. #define INT_SIZE_LENGTH 20
  13. #define LONG_SIZE_LENGTH 40
  14. #define I64_SIZE_LENGTH 80
  15. /***
  16. *long _wtol(wchar_t *nptr) - Convert wide string to long
  17. *
  18. *Purpose:
  19. * Converts wide string pointed to by nptr to binary.
  20. * Overflow is not detected. Because of this, we can just use
  21. * atol().
  22. *
  23. *Entry:
  24. * nptr = ptr to wide string to convert
  25. *
  26. *Exit:
  27. * return long value of the string
  28. *
  29. *Exceptions:
  30. * None - overflow is not detected.
  31. *
  32. *******************************************************************************/
  33. long __cdecl _wtol(
  34. const wchar_t *nptr
  35. )
  36. {
  37. char astring[INT_SIZE_LENGTH];
  38. WideCharToMultiByte (CP_ACP, 0, nptr, -1,
  39. astring, INT_SIZE_LENGTH, NULL, NULL);
  40. return (atol(astring));
  41. }