summaryrefslogtreecommitdiffstats
path: root/private/crt32/convert/xtow.c
blob: 2b1c0605a6158bab6806ed8a80dbfe7caf80197d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***
*xtow.c - convert integers/longs to wide char string
*
*	Copyright (c) 1993, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	The module has code to convert integers/longs to wide char strings.
*
*Revision History:
*	09-10-93  CFW	Module created, based on ASCII version.
*
*******************************************************************************/

#include <windows.h>
#include <stdlib.h>

#define INT_SIZE_LENGTH   20
#define LONG_SIZE_LENGTH  40

/***
*wchar_t *_itow, *_ltow, *_ultow(val, buf, radix) - convert binary int to wide
*	char string
*
*Purpose:
*	Converts an int to a wide character string.
*
*Entry:
*	val - number to be converted (int, long or unsigned long)
*	int radix - base to convert into
*	wchar_t *buf - ptr to buffer to place result
*
*Exit:
*	calls ASCII version to convert, converts ASCII to wide char into buf
*	returns a pointer to this buffer
*
*Exceptions:
*
*******************************************************************************/

wchar_t * _CRTAPI1 _itow (
	int val,
	wchar_t *buf,
	int radix
	)
{
   char astring[INT_SIZE_LENGTH];

   _itoa (val, astring, radix);
   MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, astring, -1,
                        buf, INT_SIZE_LENGTH);

   return (buf);
}

wchar_t * _CRTAPI1 _ltow (
	long val,
	wchar_t *buf,
	int radix
	)
{
   char astring[LONG_SIZE_LENGTH];

   _ltoa (val, astring, radix);
   MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, astring, -1,
                        buf, LONG_SIZE_LENGTH);

   return (buf);
}

wchar_t * _CRTAPI1 _ultow (
	unsigned long val,
	wchar_t *buf,
	int radix
	)
{
   char astring[LONG_SIZE_LENGTH];

   _ultoa (val, astring, radix);
   MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, astring, -1,
                        buf, LONG_SIZE_LENGTH);

   return (buf);
}