'iconv'에 해당되는 글 3건

  1. 2017.11.13 iconv - UTF8toEUCKR / EUCKRtoUTF8

반응형

 

/******************************************************************************/
/*** "iconv -l" character_set_list_check ***/
/******************************************************************************/

int iUTF8toEUCKR(char *pchFromBuff, char *pchToBuff, int iToMaxSize)
{
    iconv_t     cd;
    size_t      iLeng;
    size_t      iInByte = strlen(pchFromBuff);

    /*** iconv_open(tocode, fromcode) ***/

    cd = iconv_open("EUC-KR", "UTF-8");  /*** UTF-8 => EUC-KR ***/

    if( cd == (iconv_t)-1 ) {
        return(-1);
    }

    iLeng = iconv(cd, (char **)&pchFromBuff, &iInByte, &pchToBuff, (size_t *)&iToMaxSize);
    iconv_close(cd);

    return(iLeng);
}

/******************************************************************************/

int iEUCKRtoUTF8(char *pchFromBuff, char *pchToBuff, int iToMaxSize)
{
    iconv_t     cd;
    size_t      iLeng;
    size_t      iInByte = strlen(pchFromBuff);

    /*** iconv_open(tocode, fromcode) ***/

    cd = iconv_open("UTF-8", "EUC-KR");  /*** EUC-KR => UTF-8 ***/

    if( cd == (iconv_t)-1 ) {
        return(-1);
    }

    iLeng = iconv(cd, (char **)&pchFromBuff, &iInByte, &pchToBuff, (size_t *)&iToMaxSize);
    iconv_close(cd);

    return(iLeng);
}

/******************************************************************************/

 

 

반응형
Posted by 공간사랑
,