'UTF8ToAnsi'에 해당되는 글 1건

  1. 2009.07.17 utf-8 문자열 ansi로 변환

int CUtility::UTF_8ToAnsi(const char* pSrc, char* pDest, int nOut)
 {
  int ret;
  wchar_t *wc;
  char *Temp;

  wc = (wchar_t*)malloc(sizeof(wchar_t)*(nOut+1));
  memset(wc,0,sizeof(wchar_t)*(nOut+1));

  if(nOut==0)
  {
   free(wc);
   return ::MultiByteToWideChar( CP_UTF8, 0, pSrc, -1, NULL, 0);
  }

  else
  {
   ret = ::MultiByteToWideChar( CP_UTF8, 0, pSrc, nOut, wc, nOut+1); // UTF-8 to UCS-2
   USES_CONVERSION;
   Temp = W2A( wc ); // UCS-2 to ANSI
   memcpy(pDest,Temp,nOut);
   free(wc);
   return ret;
  }
 }

Posted by 명혀니
,