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.

59 lines
1.5 KiB

  1. /***
  2. *xtow.c - convert integers/longs to wide char string
  3. *
  4. * Copyright (c) 1993, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * The module has code to convert integers/longs to wide char strings.
  8. *
  9. *Revision History:
  10. * 09-10-93 CFW Module created, based on ASCII version.
  11. *
  12. *******************************************************************************/
  13. #include <windows.h>
  14. #include <stdlib.h>
  15. #define INT_SIZE_LENGTH 20
  16. #define LONG_SIZE_LENGTH 40
  17. /***
  18. *BOOL our_ultow(val, buf, bufsize, radix) - convert binary int to wide
  19. * char string
  20. *
  21. *Purpose:
  22. * Converts an int to a wide character string.
  23. *
  24. *Entry:
  25. * val - number to be converted (int, long or unsigned long)
  26. * int radix - base to convert into
  27. * wchar_t *buf - ptr to buffer to place result
  28. * int bufsize - size of buffer pointed to by buf, in characters
  29. *
  30. *Exit:
  31. * calls ASCII version to convert, converts ASCII to wide char into buf
  32. * returns TRUE if char. conversion succeeded, FALSE otherwise.
  33. *
  34. *Exceptions:
  35. *
  36. *******************************************************************************/
  37. BOOL __cdecl our_ultow(
  38. unsigned long val,
  39. wchar_t *buf,
  40. int bufsize,
  41. int radix
  42. )
  43. {
  44. char astring[LONG_SIZE_LENGTH];
  45. _ultoa (val, astring, radix);
  46. return (MultiByteToWideChar(CP_ACP,
  47. MB_PRECOMPOSED,
  48. astring,
  49. -1,
  50. buf,
  51. bufsize) == 0 ? FALSE : TRUE);
  52. }