문자열 변환 함수
-
// char(ANSI Code set) -> wchar(UNI code set) 변환
-
wchar_t* CharToWChar(const char* pstrSrc)
-
{
-
int nLen = (int)strlen(pstrSrc) + 1;
-
//wchar_t* pwstr = (wchar_t*) malloc ( sizeof( wchar_t )* nLen);
-
wchar_t* pwstr = new wchar_t[sizeof(wchar_t)* nLen];
-
int wnLen = sizeof(wchar_t)* nLen;
-
-
MultiByteToWideChar(CP_ACP, 0, pstrSrc, nLen, pwstr, wnLen);
-
-
return pwstr;
-
}
-
-
// wchar(UNI code set) -> char(ANSI Code set) 변환
-
char* WCharToChar(const wchar_t* pwstrSrc)
-
{
-
int nwLen = (int)wcslen(pwstrSrc) * 2;
-
//char* pstr = (char*) malloc ( sizeof( char) * nwLen + 1);
-
char* pstr = new char[sizeof(char)* nwLen + 1];
-
int nLen = sizeof(char)* nwLen + 1;
-
-
WideCharToMultiByte(CP_ACP, 0, pwstrSrc, (wcslen(pwstrSrc) + 1) * 2, pstr, nLen, NULL, NULL);
-
-
return pstr;
-
}
-
-
// UTF8 code set -> wchar(UNI code set) 변환
-
wchar_t* UTF8ToWChar(const char* pstrSrc)
-
{
-
int nLen = (int)strlen(pstrSrc) + 1;
-
//wchar_t* pwstr = (wchar_t*) malloc ( sizeof( wchar_t )* nLen);
-
wchar_t* pwstr = new wchar_t[sizeof(wchar_t)* nLen];
-
int wnLen = sizeof(wchar_t)* nLen;
-
-
MultiByteToWideChar(CP_UTF8, 0, pstrSrc, nLen, pwstr, wnLen);
-
-
return pwstr;
-
}
-
-
// wchar -> UFT8 변환
-
char* WCharToUTF8(const wchar_t* pwstrSrc)
-
{
-
int nwLen = (int)wcslen(pwstrSrc) * 3;
-
//char* pstr = (char*) malloc ( sizeof( char) * nwLen + 1);
-
char* pstr = new char[sizeof(char)* nwLen + 1];
-
int nLen = sizeof(char)* nwLen + 1;
-
-
WideCharToMultiByte(CP_UTF8, 0, pwstrSrc, (wcslen(pwstrSrc) + 1) * 2, pstr, nLen, NULL, NULL);
-
-
return pstr;
-
}
-
wchar_t* CharToWChar(const char* pstrSrc); // char(ANSI Code set) -> wchar(UNI code set) 변환
-
char* WCharToChar(const wchar_t* pwstrSrc); // wchar(UNI code set) -> char(ANSI Code set) 변환
-
wchar_t* UTF8ToWChar(const char* pstrSrc); // UTF8 code set -> wchar(UNI code set) 변환
-
char* WCharToUTF8(const wchar_t* pwstrSrc); // wchar(UNI code set) -> UFT8 변환
'서버개발자 > C언어' 카테고리의 다른 글
while문, do while문 (0) | 2014.05.25 |
---|---|
malloc (0) | 2014.04.16 |
C언어 구조체 에러가 좀 있음 출력은 되는데 (0) | 2014.04.06 |
입출금 소스 (2) | 2014.04.02 |
C 언어 (0) | 2014.04.02 |