📄 quotedprintable.cc
字号:
/* Name : quotedprintable** File : quotedprintable.h** Author : Inconnu** Description : Permet d'encoder et de decoder des caractere accentues QUOTED-PRINTABLE**** Version : ** Note : ** Mail : ** Copyright : */#include <stdio.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <string>using namespace std;void enc_quotedP(string & str){ ostringstream buf; ostringstream hexa; string hexaVal; for(int i=0;i<str.size();++i) { unsigned int carac = (unsigned) str[i]; if ( carac > 127 ) //encodage sur 2 octets { unsigned int carac2 = (unsigned) str[++i]; carac = (carac-192)<<6; carac2 = carac2 - 128; carac = carac + carac2; hexa << hex << carac; hexaVal = hexa.str(); if (buf.str().size()%76 < 71) buf << "=" << hexaVal.substr(hexaVal.size()-2,hexaVal.size()); else buf << "=\r\n=" << hexaVal.substr(hexaVal.size()-2,hexaVal.size()); hexa << flush; hexaVal.clear(); } else if (buf.str().size()%76 < 73) //encodage sur 1 octet buf << str[i]; else buf << "=\r\n" << str[i]; } str = buf.str();}void dec_quotedP(string & str){ ostringstream buf; for(int i=0;i<str.size();++i) { if (str[i] == '=') if (str[++i] == '\r') ++i; else { string c = str.substr(i,2); char *pEnd; short unsigned int car = strtol (c.c_str(),&pEnd,16); //on veut les 6 derniers bits + 128 int Msk = car & 63 | 128; //on veut les 2 derniers bits et on les décale de //6 positions int Msk2 = 195 ; buf << char(Msk2) << char(Msk); //buf << (char)car; ++i; } else buf << str[i]; } str = buf.str();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -