[C#] UTF-8 ENCODING=QUOTED-PRINTABLE 的解码和编码
解码:
形如
BEGIN:VCARD
VERSION:2.1
N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;[=E5=86=B7=E6=B1=9F]
FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:[=E5=86=B7=E6=B1=9F]
TEL;CELL:13099999999
X-IRMC-LUID:00020000002C
END:VCARD
这样的文件 [=E5=86=B7=E6=B1=9F] 如何解码呢
str = str.Replace("=", "%");
str = System.Web.HttpUtility.UrlDecode(str, System.Text.Encoding.UTF8);
str = System.Web.HttpUtility.UrlDecode(str, System.Text.Encoding.UTF8);
这样 解码出来就能看懂了
下面是编码方式 粘贴来的不解释
int j = -1;
for (int i = 0; i < b.Length; i++)
{
if (b[i] == '%')
{
c += "=";
j = i;
}
if (i - j < 3 && i - j > 0 && j !=-1)
{
c += b[i].ToString().ToUpper();
}
else
{
if( b[i] !='%')
c += b[i];
}
}
-----