ABOUT ME

Today
Yesterday
Total
  • Windows Mobile에서 유니코드 변환
    공장 이야기 2009. 9. 29. 16:45

    해제는 반듯이 free로...

     

    int WCharToChar(LPCWSTR pszSour, LPSTR &pszDest)
    {
            int nLen = 0;

     

            if(NULL == pszSour)
                    return 0;

     

            nLen = WideCharToMultiByte(CP_ACP, 0, pszSour, -1, pszDest, 0, NULL, NULL);
            if(0 >= nLen)
                    return 0;
            pszDest = (char *)::malloc(nLen+1);
            ::memset(pszDest, 0, nLen+1);
            WideCharToMultiByte(CP_ACP, 0, pszSour, -1, pszDest, nLen, NULL, NULL);

     

            return nLen;
    }

     

    int CharToWChar(LPCSTR pszSour, LPWSTR &pszDest)
    {
            int nLen = 0;

     

            if(NULL == pszSour)
                    return 0;

     

            nLen = MultiByteToWideChar(CP_ACP, 0, pszSour, -1, NULL, NULL);
            if(0 >= nLen)
                    return 0;
            pszDest = (WCHAR *)::malloc((nLen+1)*sizeof(WCHAR));
            ::memset(pszDest, 0, (nLen+1)*sizeof(WCHAR));
            MultiByteToWideChar(CP_ACP, 0, pszSour, -1, pszDest, nLen);

     

            return nLen;
    }

    '공장 이야기' 카테고리의 다른 글

    SIP 설정하기  (0) 2009.10.12
    자주 사용하는 메크로...  (0) 2009.09.30
    Windows Mobile 에서 DC를 Bitmap 저장  (0) 2009.09.21
    위피에서 lrotl, lrotr 구현  (0) 2009.08.12
    Windows Mobile에서 PPP 연결...  (0) 2009.06.12
Designed by Tistory.