随笔 - 298  文章 - 377  trackbacks - 0
<2012年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(34)

随笔分类

随笔档案

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜

VC URLEncode & UrlDecode
 
#define IsHexNum(c) ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))

CString Utf8ToStringT(LPSTR str)
{
    _ASSERT(str);
    USES_CONVERSION;
    WCHAR 
*buf;
    
int length = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
    buf 
= new WCHAR[length+1];
    ZeroMemory(buf, (length
+1* sizeof(WCHAR));
    MultiByteToWideChar(CP_UTF8, 
0, str, -1, buf, length);

    
return (CString(W2T(buf)));
}

/*
CString UrlDecode(LPCTSTR url)
{
    _ASSERT(url);
    USES_CONVERSION;
    LPSTR _url = T2A(const_cast<LPTSTR>(url));
    int i = 0;
    int length = (int)strlen(_url);
    CHAR *buf = new CHAR[length];
    ZeroMemory(buf, length);
    LPSTR p = buf;
    while(i < length)
    {
        if(i <= length -3 && _url[i] == '%' && IsHexNum(_url[i+1]) && IsHexNum(_url[i+2]))
        {
            sscanf(_url + i + 1, "%x", p++);
            i += 3;
        }
        else
        {
            *(p++) = _url[i++];
        }
    }
    //return Utf8ToStringT(buf);
    return CString(buf);
}
*/

CString UrlDecode(LPCTSTR url)
{
    _ASSERT(url);
    USES_CONVERSION;
    LPSTR _url 
= T2A(const_cast<LPTSTR>(url));
    
int i = 0;
    
int length = (int)strlen(_url);
    CHAR 
*buf = new CHAR[length];
    ZeroMemory(buf, length);
    LPSTR p 
= buf;
    
char tmp[4];
    
while(i < length)
    
{
        
if(i <= length -3 && _url[i] == '%' && IsHexNum(_url[i+1]) && IsHexNum(_url[i+2]))
        
{
            memset(tmp, 
0sizeof(tmp));
            memcpy(tmp, _url 
+ i + 1,2); 
            sscanf(tmp, 
"%x", p++);
            i 
+= 3;
        }

        
else
        
{
            
*(p++= _url[i++];
        }

    }

    
return Utf8ToStringT(buf);
}


void ConvertUtf8ToGBK(CString& strUtf8) 
{
    
int len=MultiByteToWideChar(CP_UTF8, 0, (LPCTSTR)strUtf8, -1, NULL,0);
    unsigned 
short * wszGBK = new unsigned short[len+1];
    memset(wszGBK, 
0, len * 2 + 2);
    MultiByteToWideChar(CP_UTF8, 
0, (LPCTSTR)strUtf8, -1, wszGBK, len);
    len 
= WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
    
char *szGBK=new char[len + 1];
    memset(szGBK, 
0, len + 1);
    WideCharToMultiByte (CP_ACP, 
0, wszGBK, -1, szGBK, len, NULL,NULL);

    strUtf8 
= szGBK;
    delete[] szGBK;
    delete[] wszGBK;
}


void ConvertGBKToUtf8(CString& strGBK)
{
    
int len=MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strGBK, -1, NULL,0);
    unsigned 
short * wszUtf8 = new unsigned short[len+1];
    memset(wszUtf8, 
0, len * 2 + 2);
    MultiByteToWideChar(CP_ACP, 
0, (LPCTSTR)strGBK, -1, wszUtf8, len);

    len 
= WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, NULL, 0, NULL, NULL);
    
char *szUtf8=new char[len + 1];
    memset(szUtf8, 
0, len + 1);
    WideCharToMultiByte (CP_UTF8, 
0, wszUtf8, -1, szUtf8, len, NULL,NULL);

    strGBK 
= szUtf8;
    delete[] szUtf8;
    delete[] wszUtf8;
}


void UTF_8ToUnicode(WCHAR* pOut,char *pText)
{
    
char* uchar = (char *)pOut;
 
    uchar[
1= ((pText[0& 0x0F<< 4+ ((pText[1>> 2& 0x0F);
    uchar[
0= ((pText[1& 0x03<< 6+ (pText[2& 0x3F);
 
    
return;
}


// Unicode 转换成UTF-8  
void UnicodeToUTF_8(char* pOut,WCHAR* pText)
{
    
// 注意 WCHAR高低字的顺序,低字节在前,高字节在后
    char* pchar = (char *)pText;
 
    pOut[
0= (0xE0 | ((pchar[1& 0xF0>> 4));
    pOut[
1= (0x80 | ((pchar[1& 0x0F<< 2)) + ((pchar[0& 0xC0>> 6);
    pOut[
2= (0x80 | (pchar[0& 0x3F));
 
    
return;
}


// 把Unicode 转换成 GB2312  
void UnicodeToGB2312(char* pOut,unsigned short uData)
{
    WideCharToMultiByte(CP_ACP,NULL,
&uData,1,pOut,sizeof(WCHAR),NULL,NULL);
    
return;
}
   

// GB2312 转换成 Unicode
void Gb2312ToUnicode(WCHAR* pOut,char *gbBuffer)
{
    ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,gbBuffer,
2,pOut,1);
    
return;
}


//GB2312 转为 UTF-8
void GB2312ToUTF_8(CString& pOut,char *pText, int pLen)
{
    
char buf[1024];
    
char* rst = new char[pLen + (pLen >> 2+ 2];
 
    memset(buf,
0,1024);
    memset(rst,
0,pLen + (pLen >> 2+ 2);
 
    
int i = 0;
    
int j = 0;   
    
while(i < pLen)
    
{
        
//如果是英文直接复制就可以
        if*(pText + i) >= 0)
        
{
            rst[j
++= pText[i++];
        }

        
else
        
{
            WCHAR pbuffer;
            Gb2312ToUnicode(
&pbuffer,pText+i);

            UnicodeToUTF_8(buf,
&pbuffer);

            unsigned 
short int tmp = 0;
            tmp 
= rst[j] = buf[0];
            tmp 
= rst[j+1= buf[1];
            tmp 
= rst[j+2= buf[2];

            j 
+= 3;
            i 
+= 2;
        }

    }

    strcpy(
&rst[j],"\0");
 
    
//返回结果
    pOut = rst;   
    delete []rst;   

    
return;
}


//UTF-8 转为 GB2312
void UTF_8ToGB2312(CString &pOut, char *pText, int pLen)
{
    
char * newBuf = new char[pLen];
    
char Ctemp[4];
    memset(Ctemp,
0,4);
 
    
int i =0;
    
int j = 0;
 
    
while(i < pLen)
    
{
        
if(pText[i] > 0)
        
{
            newBuf[j
++= pText[i++];   
        }

        
else   
        
{
            WCHAR Wtemp;
            UTF_8ToUnicode(
&Wtemp,pText + i);

            UnicodeToGB2312(Ctemp,Wtemp);

            newBuf[j] 
= Ctemp[0];
            newBuf[j 
+ 1= Ctemp[1];

            i 
+= 3;   
            j 
+= 2;   
        }

    }

    strcpy(
&newBuf[j],"\0");
 
    pOut 
= newBuf;
    delete []newBuf;
 
    
return;  
}



CString UTF8_Encode(LPTSTR strUnicode)   
{   
    
long TLen ;   
    CString UTF8_EncodeLong ;   

    TLen 
= CString(strUnicode).GetLength() ;   

    
if(TLen == 0)   
    
{   
        
return CString(strUnicode);   
    }
   

    
long lngBufferSize ;   
    
long lngResult ;   

    
//Set buffer for longest possible string.   
    lngBufferSize = TLen * 3 + 1 ;   
    
char *bytUtf8 = new char[lngBufferSize] ;   

    
//Translate using code page 65001(UTF-8).   

    lngResult 
= WideCharToMultiByte(CP_UTF8, 0, (unsigned short*)strUnicode, TLen, bytUtf8, lngBufferSize, NULL, 0) ;   

    bytUtf8[lngResult] 
= NULL ;   

    
return CString(bytUtf8) ;
}

/*************************************************************************/
inline BYTE toHex(
const BYTE &x)
{
 
return x > 9 ? x + 55: x + 48;
}


CString URLEncode(CString sIn)
{
CString sOut;
const int nLen = sIn.GetLength() + 1;
register LPBYTE pOutTmp 
= NULL;
LPBYTE pOutBuf 
= NULL;
register LPBYTE pInTmp 
= NULL;
LPBYTE pInBuf 
=(LPBYTE)sIn.GetBuffer(nLen);
BYTE b 
= 0;

//alloc out buffer
pOutBuf = (LPBYTE)sOut.GetBuffer(nLen*3 - 2);//new BYTE [nLen * 3];

if(pOutBuf)
{
pInTmp 
= pInBuf;
pOutTmp 
= pOutBuf;

// do encoding
while (*pInTmp)
{
if(isalnum(*pInTmp))
*pOutTmp++ = *pInTmp;
else
if(isspace(*pInTmp))
*pOutTmp++ = '+';
else
{
*pOutTmp++ = '%';
*pOutTmp++ = toHex(*pInTmp>>4);
*pOutTmp++ = toHex(*pInTmp%16);
}

pInTmp
++;
}

*pOutTmp = '\0';
//sOut=pOutBuf;
//delete [] pOutBuf;
sOut.ReleaseBuffer();
}

sIn.ReleaseBuffer();
return sOut;
}

 

http://blog.csdn.net/leechiyang/archive/2008/02/22/2112915.aspx

http://blog.csdn.net/zhengyun_ustc/archive/2002/05/20/12654.aspx

URLEncode:
inline BYTE toHex(const BYTE &x)
{
return x > 9 ? x + 55: x + 48;
}

CString URLEncode(CString sIn)
{
CString sOut;
const int nLen = sIn.GetLength() + 1;
register LPBYTE pOutTmp = NULL;
LPBYTE pOutBuf = NULL;
register LPBYTE pInTmp = NULL;
LPBYTE pInBuf =(LPBYTE)sIn.GetBuffer(nLen);
BYTE b = 0;

//alloc out buffer
pOutBuf = (LPBYTE)sOut.GetBuffer(nLen*3 - 2);//new BYTE [nLen * 3];

if(pOutBuf)
{
pInTmp = pInBuf;
pOutTmp = pOutBuf;

// do encoding
while (*pInTmp)
{
if(isalnum(*pInTmp))
*pOutTmp++ = *pInTmp;
else
if(isspace(*pInTmp))
*pOutTmp++ = '+';
else
{
*pOutTmp++ = '%';
*pOutTmp++ = toHex(*pInTmp>>4);
*pOutTmp++ = toHex(*pInTmp%16);
}
pInTmp++;
}
*pOutTmp = '\0';
//sOut=pOutBuf;
//delete [] pOutBuf;
sOut.ReleaseBuffer();
}
sIn.ReleaseBuffer();
return sOut;
}

 

UrlDecode:
#define IsHexNum(c) ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))

CString Utf8ToStringT(LPSTR str)
{
_ASSERT(str);
USES_CONVERSION;
WCHAR *buf;
int length = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
buf = new WCHAR[length+1];
ZeroMemory(buf, (length+1) * sizeof(WCHAR));
MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, length);

return (CString(W2T(buf)));
}

CString UrlDecode(LPCTSTR url)
{
_ASSERT(url);
USES_CONVERSION;
LPSTR _url = T2A(const_cast<LPTSTR>(url));
int i = 0;
int length = (int)strlen(_url);
CHAR *buf = new CHAR[length];
ZeroMemory(buf, length);
LPSTR p = buf;
while(i < length)
{
if(i <= length -3 && _url[i] == '%' && IsHexNum(_url[i+1]) && IsHexNum(_url[i+2]))
{
sscanf(_url + i + 1, "%x", p++);
i += 3;
}
else
{
*(p++) = _url[i++];
}
}
return Utf8ToStringT(buf);

#define IsHexNum(c) ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))

CString Utf8ToStringT(LPSTR str)
{
    _ASSERT(str);
    USES_CONVERSION;
    WCHAR 
*buf;
    
int length = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
    buf 
= new WCHAR[length+1];
    ZeroMemory(buf, (length
+1* sizeof(WCHAR));
    MultiByteToWideChar(CP_UTF8, 
0, str, -1, buf, length);

    
return (CString(W2T(buf)));
}

/*
CString UrlDecode(LPCTSTR url)
{
    _ASSERT(url);
    USES_CONVERSION;
    LPSTR _url = T2A(const_cast<LPTSTR>(url));
    int i = 0;
    int length = (int)strlen(_url);
    CHAR *buf = new CHAR[length];
    ZeroMemory(buf, length);
    LPSTR p = buf;
    while(i < length)
    {
        if(i <= length -3 && _url[i] == '%' && IsHexNum(_url[i+1]) && IsHexNum(_url[i+2]))
        {
            sscanf(_url + i + 1, "%x", p++);
            i += 3;
        }
        else
        {
            *(p++) = _url[i++];
        }
    }
    //return Utf8ToStringT(buf);
    return CString(buf);
}
*/

CString UrlDecode(LPCTSTR url)
{
    _ASSERT(url);
    USES_CONVERSION;
    LPSTR _url 
= T2A(const_cast<LPTSTR>(url));
    
int i = 0;
    
int length = (int)strlen(_url);
    CHAR 
*buf = new CHAR[length];
    ZeroMemory(buf, length);
    LPSTR p 
= buf;
    
char tmp[4];
    
while(i < length)
    
{
        
if(i <= length -3 && _url[i] == '%' && IsHexNum(_url[i+1]) && IsHexNum(_url[i+2]))
        
{
            memset(tmp, 
0sizeof(tmp));
            memcpy(tmp, _url 
+ i + 1,2); 
            sscanf(tmp, 
"%x", p++);
            i 
+= 3;
        }

        
else
        
{
            
*(p++= _url[i++];
        }

    }

    
return Utf8ToStringT(buf);
}


void ConvertUtf8ToGBK(CString& strUtf8) 
{
    
int len=MultiByteToWideChar(CP_UTF8, 0, (LPCTSTR)strUtf8, -1, NULL,0);
    unsigned 
short * wszGBK = new unsigned short[len+1];
    memset(wszGBK, 
0, len * 2 + 2);
    MultiByteToWideChar(CP_UTF8, 
0, (LPCTSTR)strUtf8, -1, wszGBK, len);
    len 
= WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
    
char *szGBK=new char[len + 1];
    memset(szGBK, 
0, len + 1);
    WideCharToMultiByte (CP_ACP, 
0, wszGBK, -1, szGBK, len, NULL,NULL);

    strUtf8 
= szGBK;
    delete[] szGBK;
    delete[] wszGBK;
}


void ConvertGBKToUtf8(CString& strGBK)
{
    
int len=MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strGBK, -1, NULL,0);
    unsigned 
short * wszUtf8 = new unsigned short[len+1];
    memset(wszUtf8, 
0, len * 2 + 2);
    MultiByteToWideChar(CP_ACP, 
0, (LPCTSTR)strGBK, -1, wszUtf8, len);

    len 
= WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, NULL, 0, NULL, NULL);
    
char *szUtf8=new char[len + 1];
    memset(szUtf8, 
0, len + 1);
    WideCharToMultiByte (CP_UTF8, 
0, wszUtf8, -1, szUtf8, len, NULL,NULL);

    strGBK 
= szUtf8;
    delete[] szUtf8;
    delete[] wszUtf8;
}


void UTF_8ToUnicode(WCHAR* pOut,char *pText)
{
    
char* uchar = (char *)pOut;
 
    uchar[
1= ((pText[0& 0x0F<< 4+ ((pText[1>> 2& 0x0F);
    uchar[
0= ((pText[1& 0x03<< 6+ (pText[2& 0x3F);
 
    
return;
}


// Unicode 转换成UTF-8  
void UnicodeToUTF_8(char* pOut,WCHAR* pText)
{
    
// 注意 WCHAR高低字的顺序,低字节在前,高字节在后
    char* pchar = (char *)pText;
 
    pOut[
0= (0xE0 | ((pchar[1& 0xF0>> 4));
    pOut[
1= (0x80 | ((pchar[1& 0x0F<< 2)) + ((pchar[0& 0xC0>> 6);
    pOut[
2= (0x80 | (pchar[0& 0x3F));
 
    
return;
}


// 把Unicode 转换成 GB2312  
void UnicodeToGB2312(char* pOut,unsigned short uData)
{
    WideCharToMultiByte(CP_ACP,NULL,
&uData,1,pOut,sizeof(WCHAR),NULL,NULL);
    
return;
}
   

// GB2312 转换成 Unicode
void Gb2312ToUnicode(WCHAR* pOut,char *gbBuffer)
{
    ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,gbBuffer,
2,pOut,1);
    
return;
}


//GB2312 转为 UTF-8
void GB2312ToUTF_8(CString& pOut,char *pText, int pLen)
{
    
char buf[1024];
    
char* rst = new char[pLen + (pLen >> 2+ 2];
 
    memset(buf,
0,1024);
    memset(rst,
0,pLen + (pLen >> 2+ 2);
 
    
int i = 0;
    
int j = 0;   
    
while(i < pLen)
    
{
        
//如果是英文直接复制就可以
        if*(pText + i) >= 0)
        
{
            rst[j
++= pText[i++];
        }

        
else
        
{
            WCHAR pbuffer;
            Gb2312ToUnicode(
&pbuffer,pText+i);

            UnicodeToUTF_8(buf,
&pbuffer);

            unsigned 
short int tmp = 0;
            tmp 
= rst[j] = buf[0];
            tmp 
= rst[j+1= buf[1];
            tmp 
= rst[j+2= buf[2];

            j 
+= 3;
            i 
+= 2;
        }

    }

    strcpy(
&rst[j],"\0");
 
    
//返回结果
    pOut = rst;   
    delete []rst;   

    
return;
}


//UTF-8 转为 GB2312
void UTF_8ToGB2312(CString &pOut, char *pText, int pLen)
{
    
char * newBuf = new char[pLen];
    
char Ctemp[4];
    memset(Ctemp,
0,4);
 
    
int i =0;
    
int j = 0;
 
    
while(i < pLen)
    
{
        
if(pText[i] > 0)
        
{
            newBuf[j
++= pText[i++];   
        }

        
else   
        
{
            WCHAR Wtemp;
            UTF_8ToUnicode(
&Wtemp,pText + i);

            UnicodeToGB2312(Ctemp,Wtemp);

            newBuf[j] 
= Ctemp[0];
            newBuf[j 
+ 1= Ctemp[1];

            i 
+= 3;   
            j 
+= 2;   
        }

    }

    strcpy(
&newBuf[j],"\0");
 
    pOut 
= newBuf;
    delete []newBuf;
 
    
return;  
}



CString UTF8_Encode(LPTSTR strUnicode)   
{   
    
long TLen ;   
    CString UTF8_EncodeLong ;   

    TLen 
= CString(strUnicode).GetLength() ;   

    
if(TLen == 0)   
    
{   
        
return CString(strUnicode);   
    }
   

    
long lngBufferSize ;   
    
long lngResult ;   

    
//Set buffer for longest possible string.   
    lngBufferSize = TLen * 3 + 1 ;   
    
char *bytUtf8 = new char[lngBufferSize] ;   

    
//Translate using code page 65001(UTF-8).   

    lngResult 
= WideCharToMultiByte(CP_UTF8, 0, (unsigned short*)strUnicode, TLen, bytUtf8, lngBufferSize, NULL, 0) ;   

    bytUtf8[lngResult] 
= NULL ;   

    
return CString(bytUtf8) ;
}

/*************************************************************************/
inline BYTE toHex(
const BYTE &x)
{
 
return x > 9 ? x + 55: x + 48;
}


CString URLEncode(CString sIn)
{
CString sOut;
const int nLen = sIn.GetLength() + 1;
register LPBYTE pOutTmp 
= NULL;
LPBYTE pOutBuf 
= NULL;
register LPBYTE pInTmp 
= NULL;
LPBYTE pInBuf 
=(LPBYTE)sIn.GetBuffer(nLen);
BYTE b 
= 0;

//alloc out buffer
pOutBuf = (LPBYTE)sOut.GetBuffer(nLen*3 - 2);//new BYTE [nLen * 3];

if(pOutBuf)
{
pInTmp 
= pInBuf;
pOutTmp 
= pOutBuf;

// do encoding
while (*pInTmp)
{
if(isalnum(*pInTmp))
*pOutTmp++ = *pInTmp;
else
if(isspace(*pInTmp))
*pOutTmp++ = '+';
else
{
*pOutTmp++ = '%';
*pOutTmp++ = toHex(*pInTmp>>4);
*pOutTmp++ = toHex(*pInTmp%16);
}

pInTmp
++;
}

*pOutTmp = '\0';
//sOut=pOutBuf;
//delete [] pOutBuf;
sOut.ReleaseBuffer();
}

sIn.ReleaseBuffer();
return sOut;
}

}



posted on 2012-06-15 23:18 聂文龙 阅读(5418) 评论(2)  编辑 收藏 引用

FeedBack:
# re: VC URLEncode & UrlDecode 2016-01-10 00:15 聂文龙
//从 URL 专用格式字符串还原成普通字符串

#include <iconv.h>
#include <iostream>

using namespace std;

char Char2Int(char ch){
if(ch>='0' && ch<='9')return (char)(ch-'0');
if(ch>='a' && ch<='f')return (char)(ch-'a'+10);
if(ch>='A' && ch<='F')return (char)(ch-'A'+10);
return -1;
}

char Str2Bin(char *str){
char tempWord[2];
char chn;

tempWord[0] = Char2Int(str[0]); //make the B to 11 -- 00001011
tempWord[1] = Char2Int(str[1]); //make the 0 to 0 -- 00000000

chn = (tempWord[0] << 4) | tempWord[1]; //to change the BO to 10110000

return chn;
}

string UrlDecode(string str){
string output="";
char tmp[2];
int i=0,idx=0,ndx,len=str.length();

while(i<len){
if(str[i]=='%'){
tmp[0]=str[i+1];
tmp[1]=str[i+2];
output+=Str2Bin(tmp);
i=i+3;
}
else if(str[i]=='+'){
output+=' ';
i++;
}
else{
output+=str[i];
i++;
}
}

return output;
}

// 代码转换操作类 用于将utf-8 格式转成 gb2312
class CodeConverter {
private:
iconv_t cd;
public:
CodeConverter(const char *from_charset,const char *to_charset) {// 构造
cd = iconv_open(to_charset,from_charset);
}

~CodeConverter() {// 析构
iconv_close(cd);
}

int convert(char *inbuf,int inlen,char *outbuf,int outlen) {// 转换输出
char **pin = &inbuf;
char **pout = &outbuf;

memset(outbuf,0,outlen);
return iconv(cd,pin,(size_t *)&inlen,pout,(size_t *)&outlen);
}
};

//输入url_Utf-8 ,输出 gb2312
string Url2Str_Utf8(string instr){
string input;
input=UrlDecode(instr);

const int outlen=instr.length();
char output[outlen];

CodeConverter cc = CodeConverter("utf-8","gb2312");
cc.convert((char *)input.c_str(),strlen(input.c_str()),output,outlen);

return output;
}

//输入url_gb2312 ,输出 gb2312 实际上是直接调用 UrlDecode()
string Url2Str_gb2312(string str){
return UrlDecode(str);
}


//示例程序
/*int main(){
//char out2[OUTLEN];

//+中国哈哈哈终于得了^_^
cout<<"Url2String_gb2312:"<<Url2String_gb2312("%2B%D6%D0%B9%FA%B9%FE%B9%FE%B9%FE%D6%D5%D3%DA%B5%C3%C1%CB%5E_%5E")<<endl;
cout<<"Url2String_Utf8:"<<Url2String_Utf8("%2B%E4%B8%AD%E5%9B%BD%E5%93%88%E5%93%88%E5%93%88%E7%BB%88%E4%BA%8E%E5%BE%97%E4%BA%86%5E_%5E")<<endl;

// utf-8-->gb2312

//cout << "utf-8-->gb2312 in=" << out1 << ",out=" << out2 << endl;
//cout<<Url2String_Utf8(out1);

return 0;
}*/  回复  更多评论
  
# re: VC URLEncode & UrlDecode 2016-01-10 00:18 聂文龙

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理