- HOME
- Post in | and so on/문자열
- Post at | 2012. 12. 10. 10:44 | by 밀크빵.
- View comment
멀티/유니->utf8, utf8->멀티/유니
const char* uni_to_utf8(const wchar_t* unicode)
{
static CString utf8;
size_t len = wcslen(unicode);
int szutf8 = WideCharToMultiByte(CP_UTF8, 0, unicode, len, utf8.GetBufferSetLength( len * 4 ), len*4, 0, 0);
utf8.GetBufferSetLength( szutf8 );
return utf8.GetString();
}
const wchar_t* utf8_to_uni(const char* utf8)
{
static CStringW unicode;
unicode.Empty();
size_t len = strlen(utf8);
int szuni = MultiByteToWideChar(CP_UTF8, 0, utf8, len, unicode.GetBufferSetLength(len), len);
return unicode.GetBufferSetLength(szuni);
}
const char* ansi_to_utf8(const char* ansi)
{
return uni_to_utf8 (CStringW(ansi));
}
const char* utf8_to_ansi(const char* utf8)
{
static CString ansi;
ansi.Empty();
ansi = utf8_to_uni(utf8);
return ansi;
}
'and so on > 문자열' 카테고리의 다른 글
msdn (0) | 2012.12.18 |
---|---|
UTF-8, UNICODE, ANSI - 인코딩에 대하여 (0) | 2012.12.18 |
형변환 주의하기 (0) | 2012.12.10 |
[문자열] 아스키코드, 멀티바이트, 유니코드 (0) | 2012.12.10 |
wchar -> char -> String (0) | 2012.10.31 |