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.

118 lines
2.6 KiB

  1. /***
  2. *xtow.c - convert integers/longs to wide char string
  3. *
  4. * Copyright (c) 1993-2001, 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. * 02-07-94 CFW POSIXify.
  12. * 01-19-96 BWT Add __int64 versions.
  13. * 05-13-96 BWT Fix _NTSUBSET_ version
  14. * 08-21-98 GJF Bryan's _NTSUBSET_ version is the correct
  15. * implementation.
  16. *
  17. *******************************************************************************/
  18. #ifndef _POSIX_
  19. #include <windows.h>
  20. #include <stdlib.h>
  21. #define INT_SIZE_LENGTH 20
  22. #define LONG_SIZE_LENGTH 40
  23. #define I64_SIZE_LENGTH 80
  24. /***
  25. *wchar_t *_itow, *_ltow, *_ultow(val, buf, radix) - convert binary int to wide
  26. * char string
  27. *
  28. *Purpose:
  29. * Converts an int to a wide character string.
  30. *
  31. *Entry:
  32. * val - number to be converted (int, long or unsigned long)
  33. * int radix - base to convert into
  34. * wchar_t *buf - ptr to buffer to place result
  35. *
  36. *Exit:
  37. * calls ASCII version to convert, converts ASCII to wide char into buf
  38. * returns a pointer to this buffer
  39. *
  40. *Exceptions:
  41. *
  42. *******************************************************************************/
  43. wchar_t * __cdecl _itow (
  44. int val,
  45. wchar_t *buf,
  46. int radix
  47. )
  48. {
  49. char astring[INT_SIZE_LENGTH];
  50. _itoa (val, astring, radix);
  51. mbstowcs(buf, astring, INT_SIZE_LENGTH);
  52. return (buf);
  53. }
  54. wchar_t * __cdecl _ltow (
  55. long val,
  56. wchar_t *buf,
  57. int radix
  58. )
  59. {
  60. char astring[LONG_SIZE_LENGTH];
  61. _ltoa (val, astring, radix);
  62. mbstowcs(buf, astring, LONG_SIZE_LENGTH);
  63. return (buf);
  64. }
  65. wchar_t * __cdecl _ultow (
  66. unsigned long val,
  67. wchar_t *buf,
  68. int radix
  69. )
  70. {
  71. char astring[LONG_SIZE_LENGTH];
  72. _ultoa (val, astring, radix);
  73. mbstowcs(buf, astring, LONG_SIZE_LENGTH);
  74. return (buf);
  75. }
  76. #ifndef _NO_INT64
  77. wchar_t * __cdecl _i64tow (
  78. __int64 val,
  79. wchar_t *buf,
  80. int radix
  81. )
  82. {
  83. char astring[I64_SIZE_LENGTH];
  84. _i64toa (val, astring, radix);
  85. mbstowcs(buf, astring, I64_SIZE_LENGTH);
  86. return (buf);
  87. }
  88. wchar_t * __cdecl _ui64tow (
  89. unsigned __int64 val,
  90. wchar_t *buf,
  91. int radix
  92. )
  93. {
  94. char astring[I64_SIZE_LENGTH];
  95. _ui64toa (val, astring, radix);
  96. mbstowcs(buf, astring, I64_SIZE_LENGTH);
  97. return (buf);
  98. }
  99. #endif /* _NO_INT64 */
  100. #endif /* _POSIX_ */