You could try this:
- Getting length of string
- Initialize a new Unicode String with the pointer on the first element of your input
Foreach sign in your string make a static_cast and copy this to your ASCII-string
char* GetASCII(const wchar_t* wstr)
{
int count = wcslen(wstr);
char* ascii = new char[count + 1];
wchar_t* pwchr = const_cast<wchar_t*> (&wstr[0]);
for(int j = 0; j < count; ++j)
{
ascii [j] = static_cast<char> (*pwchr);
pwchr++;
}
ascii [count] = '\0';
return ascii ;
}
于 2012-12-13T09:06:28.327 回答