我简单的调用CBase64中Decode(LPCTSTR szDecoding, LPTSTR szOutput ),把乱码传进去,
可是传出来的szOutput全部为0,怎么回事?
可是传出来的szOutput全部为0,怎么回事?
解决方案 »
- 通宵没解决问题,求谁能给个 TCP 粘包处理的 例子啊,解帧头,解帧长度,解帧 消息体 这种模式的
- 关于ODBC1.0 和ODBC 3.0函数应用的问题
- VC添加类的问题(初学者求教)
- 怎么样判断一个菜单项是否有子菜单
- WINXP/2K下如何读取,硬盘,内存大小,如何得到CPU 工作频率。
- 多个线程处理大量的数据,为什么CPU内核时间占掉一大半?
- 百分求教View中实时显示的问题!
- Visual C++网络高级编程的源程序,麻烦给我发一份 。
- DCOM的智能指针的问题。请各位高手帮忙。
- 400分獻上,請你一起來做ActiveX部件的數字簽名!!
- 对于各个.h和.cpp文件分工如何,我的各种函数各个变量到底该放在哪个文件中的哪个class中?
- 在Dialog窗口中的默认中没有最大化和最小化,请问怎样让Dialog有最大化和最小化呢?
Base64的编码方式是:将原始数据转换成二进制,然后再每6位取数据,组成一个字符。解码时反过来就行了。
*s_Coded表示是经过编码的字符串;*s_Decode表示是输出的解过码的字符串;n_Len表示s_Coded的长度。
unsigned short i,t,k; //t表示尾部剩余的不足4字节数据的长度。
t = n_Len % 4;
for(i = 0; i < n_Len/4; i++)
{
s_Decode[3*i] = (s_Coded[4*i] << 2) & 0xfc + (s_Coded[4*i+1] >> 4) & 0x03;
s_Decode[3*i+1] = (s_Coded[4*i+1] << 4) & 0xf0 + (s_Coded[4*i+2] >> 2) & 0x0f;
s_Decode[3*i+2] = (s_Coded[4*i+2] << 6) & 0xc0 + s_Coded[4*i+3] & 0x3f;
}unsigned char tail[4]; //处理尾部数据
for(k = 0; k < 4; k++) //置0
tail[k] = 0;
for(k = 0; k < t; k++)
tail[k] = s_Coded[4*i+k];if(t > 0)
s_Decode[3*i] = (tail[0] << 2) & 0xfc + (tail[1] >> 4) & 0x03;
if(t > 1)
s_Decode[3*i+1] = (tail[1] << 4) & 0xf0 + (tail[2] >> 2) & 0x0f;
if(t > 2)
s_Decode[3*i+2] = (tail[2] << 6) & 0xc0 + tail[3] & 0x3f;代码写得比较粗糙,请谅解。
Base64的编码方式是:将原始数据转换成二进制,然后再每6位取数据,组成一个字符。解码时反过来就行了。
*s_Coded表示是经过编码的字符串;*s_Decode表示是输出的解过码的字符串;n_Len表示s_Coded的长度。
unsigned short i,t,k; //t表示尾部剩余的不足4字节数据的长度。
t = n_Len % 4;
for(i = 0; i < n_Len/4; i++)
{
s_Decode[3*i] = (s_Coded[4*i] << 2) & 0xfc + (s_Coded[4*i+1] >> 4) & 0x03;
s_Decode[3*i+1] = (s_Coded[4*i+1] << 4) & 0xf0 + (s_Coded[4*i+2] >> 2) & 0x0f;
s_Decode[3*i+2] = (s_Coded[4*i+2] << 6) & 0xc0 + s_Coded[4*i+3] & 0x3f;
}unsigned char tail[4]; //处理尾部数据
for(k = 0; k < 4; k++) //置0
tail[k] = 0;
for(k = 0; k < t; k++)
tail[k] = s_Coded[4*i+k];if(t > 0)
s_Decode[3*i] = (tail[0] << 2) & 0xfc + (tail[1] >> 4) & 0x03;
if(t > 1)
s_Decode[3*i+1] = (tail[1] << 4) & 0xf0 + (tail[2] >> 2) & 0x0f;
if(t > 2)
s_Decode[3*i+2] = (tail[2] << 6) & 0xc0 + tail[3] & 0x3f;代码写得比较粗糙,请谅解。
Base64的编码方式是:将原始数据转换成二进制,然后再每6位取数据,组成一个字符。解码时反过来就行了。
*s_Coded表示是经过编码的字符串;*s_Decode表示是输出的解过码的字符串;n_Len表示s_Coded的长度。
unsigned short i,t,k; //t表示尾部剩余的不足4字节数据的长度。
t = n_Len % 4;
for(i = 0; i < n_Len/4; i++)
{
s_Decode[3*i] = (s_Coded[4*i] << 2) & 0xfc + (s_Coded[4*i+1] >> 4) & 0x03;
s_Decode[3*i+1] = (s_Coded[4*i+1] << 4) & 0xf0 + (s_Coded[4*i+2] >> 2) & 0x0f;
s_Decode[3*i+2] = (s_Coded[4*i+2] << 6) & 0xc0 + s_Coded[4*i+3] & 0x3f;
}unsigned char tail[4]; //处理尾部数据
for(k = 0; k < 4; k++) //置0
tail[k] = 0;
for(k = 0; k < t; k++)
tail[k] = s_Coded[4*i+k];if(t > 0)
s_Decode[3*i] = (tail[0] << 2) & 0xfc + (tail[1] >> 4) & 0x03;
if(t > 1)
s_Decode[3*i+1] = (tail[1] << 4) & 0xf0 + (tail[2] >> 2) & 0x0f;
if(t > 2)
s_Decode[3*i+2] = (tail[2] << 6) & 0xc0 + tail[3] & 0x3f;代码写得比较粗糙,请谅解。
email: [email protected]
谢谢了
[email protected]