My guess is that the function you posted is below where you call it. Try declaring it at the top of your program, if that doesn't work, show us the whole program.
void wtoc(char* Dest,const wchar_t *Source)
{
int i = 0;
while(Source[i] != '\0')
{
Dest[i] = (char)Source[i];
++i;
}
}
As Zaccheus suggested, you have probably declared your function in the [nested] namespace, but defined it as a global.
Off-top:
1. Your destination string is NOT zero-terminated
2. I don't think this is how you convert wide char to char
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
2. I don't think this is how you convert wide char to char
The precise conversion is dependent on the source and destination encoding, of course, which is distinct from but related to the char size. So long as only (7-bit) ASCII text is present and the wide characters use UCS-2 or UTF-16, simply casting to char should work. A full conversion from UTF-16 to UTF-8 would require more complex logic, of course.
The precise conversion is dependent on the source and destination encoding, of course, which is distinct from but related to the char size. So long as only (7-bit) ASCII text is present and the wide characters use UCS-2 or UTF-16, simply casting to char should work. A full conversion from UTF-16 to UTF-8 would require more complex logic, of course.
This statement is similar to:
Code:
void longtoc(char* Dest,const long Source)
{
*Dest = (char)Source;
}
function will convert long value to char, provided that only 7-bit values were used
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
To properly convert wchar_t to char you may use wcsrtombs() standard function. You may specify any encoding to use and the function is completely safe.
Bookmarks