iconv 문자열 변환 질문입니다.
글쓴이: park3250 / 작성시간: 화, 2016/07/26 - 3:41오후
안녕하세요
윈도우에서 문자열 변환하는걸 리눅스로 포팅하려고 하는데요
iconv로 처리하고 싶은데 혹시 어떻게 하면 될까요?
inline LPSTR WINAPI _W2UTF8Helper(LPSTR lpu, LPCWSTR lpw, int nChars) { assert(lpu != NULL); assert(lpw != NULL); if (lpu == NULL || lpw == NULL) return NULL; lpu[0] = '\0'; int ret = WideCharToMultiByte(CP_UTF8, 0, lpw, -1, lpu, nChars, 0, 0); if (ret == 0) { assert(FALSE); return NULL; } return lpu; } inline LPWSTR WINAPI _A2WHelper(LPWSTR lpw, LPCSTR lpa, int nChars) { assert(lpw != NULL); assert(lpa != NULL); if (lpw == NULL || lpa == NULL) return NULL; lpw[0] = '\0'; int ret = MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars); if (ret == 0) { assert(FALSE); return NULL; } return lpw; } #define UTF8_CONVERSION int _conv_uc; (_conv_uc); LPCWSTR _lpw_uc; (_lpw_uc); LPCSTR _lpa_uc; (_lpa_uc); LPCSTR _lpu_uc; (_lpu_uc); #define A2UTF8(lpa) (\ ((_lpa_uc = lpa) == NULL) ? NULL : (\ _conv_uc = MultiByteToWideChar(CP_ACP, 0, _lpa_uc, -1, NULL, 0) * sizeof(WCHAR),\ _lpw_uc = _A2WHelper((LPWSTR)_alloca(_conv_uc), _lpa_uc, _conv_uc),\ _conv_uc = WideCharToMultiByte(CP_UTF8, 0, _lpw_uc, -1, NULL, 0, 0, 0) * sizeof(CHAR),\ _W2UTF8Helper((LPSTR)_alloca(_conv_uc), _lpw_uc, _conv_uc))) #define W2UTF8(lpw) (\ ((_lpw_uc = lpw) == NULL) ? NULL : (\ _conv_uc = WideCharToMultiByte(CP_UTF8, 0, _lpw_uc, -1, NULL, 0, 0, 0) * sizeof(CHAR),\ _W2UTF8Helper((LPSTR)_alloca(_conv_uc), _lpw_uc, _conv_uc)))
답변을 부탁드리겠습니다..
Forums:
댓글 달기