MIME之Quoted-Printable编解码
来源:互联网 发布:个体软件过程 编辑:程序博客网 时间:2024/05/18 00:54
先上一个解码的,c++风格的。
void DecodeQuoted(const std::string& v_strSrc, std::string& v_strDst) { std::string::size_type i = 0; char pDst[sizeof(int)+1] = {0}; const char* pSrc = v_strSrc.c_str(); while (i < v_strSrc.size()) { if (strncmp(pSrc+i, "=\r\n", 3) == 0){ // 软回车,跳过 i += 3; } else { if (pSrc[i] == '='){ // 是编码字节 sscanf(pSrc+i, "=%02X", (unsigned int*)pDst); v_strDst.append(pDst); i += 3; } else{ // 非编码字节 v_strDst.push_back(pSrc[i]); i++; } } }}
再上一个编码的,c风格的
int EncodeQuoted(const unsigned char* pSrc, char* pDst, int nSrcLen, int nMaxLineLen){ int nDstLen; // 输出的字符计数 int nLineLen; // 输出的行长度计数 nDstLen = 0; nLineLen = 0; for (int i = 0; i < nSrcLen; i++, pSrc++) { // ASCII 33-60, 62-126原样输出,其余的需编码 if ((*pSrc >= '!') && (*pSrc <= '~') && (*pSrc != '=')) { *pDst++ = (char)*pSrc; nDstLen++; nLineLen++; } else { sprintf(pDst, "=%02X", *pSrc); pDst += 3; nDstLen += 3; nLineLen += 3; } // 输出换行? if (nLineLen >= nMaxLineLen - 3) { sprintf(pDst, "=\r\n"); pDst += 3; nDstLen += 3; nLineLen = 0; } } // 输出加个结束符 *pDst = '\0'; return nDstLen;}
相关网址:http://biancheng.dnbcw.info/216/216040.html
0 0
- MIME之Quoted-Printable编解码
- MIME之Quoted-Printable编解码
- MIME之Quoted-Printable编解码
- MIME之Quoted-Printable编解码 选择自 bhw98 的 Blog
- python模块之quopri: quoted-printable编解码
- python模块之quopri: quoted-printable编解码
- eml之quoted-printable 解码
- MIME and Quoted-printable
- Qt quoted Printable 解码
- 用于Quoted-Printable编解码的JAVA类
- quoted-printable 编码与解码
- Quoted-Printable编码/解码c#类代码
- Quoted-Printable解码后为何还是乱码
- MIME之Base64编解码
- MIME之Base64编解码
- Quoted-Printable
- C#导出VCF格式电话本,遇到QUOTED-PRINTABLE编码的问题,附带QUOTED-PRINTABLE编码解码
- C# 对Quoted-Printable进行解码的方法
- 安装oracle遇到问题解决方法
- 洛谷 P2850 [USACO06DEC]虫洞Wormholes
- 3516a HI_MPI_IVE_GMM 跑不通
- 四道算法面试题
- 在androidstudio2.2上使用ffmpeg动态库
- MIME之Quoted-Printable编解码
- 为什么要放弃python2 使用python3
- Servlet3.0注解@WebInitParam和@WebServlet
- django 版本 语言支持 python
- springmvc validator验证的使用
- linux常用命令总结
- 【C++】学习笔记一
- Processing of multipart/form-data request failed. Stream ended unexpectedly
- VS2010 WEB开发 提示框