character
- char:
prefix withstr
ANSI:strcat( )
,strcpy( )
,strlen( )
- wchar_t :
prefix withwcs
Unicode:wcscat()
,wcscpy()
,wcslen()
- WCHAR:
typedef wchar_t WCHAR
WCHAR == wchar_t
macro_UNICODE
inc
, macroUNICODE
inwindows
if no macro defined, system useANSI
compiling and run.
- TCHAR:
Condition define type
If macroUNICODE
definedtypedef wchar_t TCHAR;
If nottypedef char TCHAR;
checkout
1 |
|
From VS2005 C++’s encoding use UNICODE
in default.
translate
char -> wchar_t1
2
3
4
5
6
7
8
9wchar_t* Util::CharToWchar(char* c)
{
int length = strlen(c) + 1; // the text end \0 [0x00] [EOF]
wchar_t *wide = (wchar_t*)malloc(sizeof(wchar_t)*length);
memset(t, 0, length * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, c, strlen(c), wide, length);
//wcout << wide << endl;
return wide;
}
wchar_t -> char1
2
3
4
5
6
7
8
9
10char* Util::WcharToChar(wchar_t* wc)
{
int length = wcslen(wc) + 1;
cout << length1 << endl;
char *c = new char[length1];
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, wc, -1,
c, length, NULL, NULL);
cout << c << endl;
return c;
}