Message29420
Logged In: YES
user_id=1200846
Sorry, if you don't mind, can you try another program?
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
void count(LPCWSTR w, int size)
{
char *buf;
int i, ret;
ret = WideCharToMultiByte(
CP_ACP,
0,
w,
size,
NULL,
0,
NULL,
NULL
);
if (ret == 0)
{
printf("error\n");
return;
}
printf("required = %d, ", ret);
buf = (char*)malloc(ret);
ret = WideCharToMultiByte(
CP_ACP,
0,
w,
size,
buf,
ret,
NULL,
NULL
);
printf("written = %d\n", ret);
for (i = 0; i < ret; ++i)
{
printf("%d ", (int)buf[i]);
}
printf("\n");
free(buf);
}
int main()
{
count(L"encode me", 9);
count(L"encode me", 10);
}
////////////////////////////
// Result on Win2000
R:\>a
required = 9, written = 9
101 110 99 111 100 101 32 109 101
required = 10, written = 10
101 110 99 111 100 101 32 109 101 0
On Windows, "required buffer size" equals to "written size"
and I thought this is always true. But I noticed that there
is not such statements in MSDN document.
Maybe on xbox, "required buffer size" is more than really
required size like this...
////////////////////////////
// Maybe on xbox....?
R:\>a
required = 10, written = 9
101 110 99 111 100 101 32 109 101
required = 11, written = 10
101 110 99 111 100 101 32 109 101 0
|
|
Date |
User |
Action |
Args |
2007-08-23 14:41:49 | admin | link | issue1532726 messages |
2007-08-23 14:41:49 | admin | create | |
|