CNewNxuEncoding.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:23k
源码类别:

搜索引擎

开发平台:

C#

  1. /*
  2.       '       迅龙中文分类搜索引擎  v0.6
  3.       '
  4.       '        LGPL  许可发行
  5.       '
  6.       '       宁夏大学  张冬 康彩  zd4004@163.com
  7.       ' 
  8.       '        官网 http://blog.163.com/zd4004/
  9.  */
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. using System.IO;
  14. using System.IO.Compression;
  15. using System.Collections;
  16. namespace NewNxuEncoding
  17. {
  18.     public class CNewNxuEncoding
  19.     {
  20.         public Hashtable myHashtable =new  Hashtable();
  21.        public CNewNxuEncoding()
  22.        {
  23.          myHashtable = NewBaseDataList();
  24.     
  25.        }
  26.         /// <summary>
  27.         /// 读取文件编码为BASE64
  28.         /// </summary>
  29.         /// <param name="FilePathX">需要转换的文件路径</param>
  30.         public String EncodeWithString(String FilePathX)
  31.         {
  32.             System.IO.FileStream inFile;
  33.             byte[] binaryData;
  34.             try
  35.             {
  36.                 inFile = new System.IO.FileStream(FilePathX,
  37.                                                   System.IO.FileMode.Open,
  38.                                                   System.IO.FileAccess.Read);
  39.                 binaryData = new Byte[inFile.Length];
  40.                 long bytesRead = inFile.Read(binaryData, 0,
  41.                                             (int)inFile.Length);
  42.                 inFile.Close();
  43.             }
  44.             catch (System.Exception exp)
  45.             {
  46.                 // Error creating stream or reading from it.
  47.                 System.Console.WriteLine("{0}", exp.Message);
  48.                 return "Error";
  49.             }
  50.             // Convert the binary input into Base64 UUEncoded output.
  51.             string base64String;
  52.             try
  53.             {
  54.                 base64String =
  55.                    System.Convert.ToBase64String(binaryData,
  56.                                                  0,
  57.                                                  binaryData.Length);
  58.                 return base64String;
  59.             }
  60.             catch (System.ArgumentNullException)
  61.             {
  62.                 System.Console.WriteLine("Binary data array is null.");
  63.                 return "Error";
  64.             }
  65.         }
  66.         /// <summary>
  67.         /// 把编码转换为BIN写入文件
  68.         /// </summary>
  69.         /// <param name="FilePathX">文件路径</param>
  70.         /// <param name="base64String">需要转换后写入的数据</param>
  71.         public void DecodeWithString(String FilePathX, string base64String)
  72.         {
  73.             //System.IO.StreamReader inFile;
  74.             byte[] binaryData;
  75.             try
  76.             {
  77.                 binaryData =
  78.                     System.Convert.FromBase64String(base64String);
  79.             }
  80.             catch (System.ArgumentNullException)
  81.             {
  82.                 System.Console.WriteLine("Base 64 string is null.");
  83.                 return;
  84.             }
  85.             catch (System.FormatException)
  86.             {
  87.                 System.Console.WriteLine("Base 64 string length is not " +
  88.                     "4 or is not an even multiple of 4.");
  89.                 return;
  90.             }
  91.             // Write out the decoded data.
  92.             System.IO.FileStream outFile;
  93.             try
  94.             {
  95.                 outFile = new System.IO.FileStream(FilePathX,
  96.                                                    System.IO.FileMode.Create,
  97.                                                    System.IO.FileAccess.Write);
  98.                 outFile.Write(binaryData, 0, binaryData.Length);
  99.                 outFile.Close();
  100.             }
  101.             catch (System.Exception exp)
  102.             {
  103.                 // Error creating stream or writing to it.
  104.                 System.Console.WriteLine("{0}", exp.Message);
  105.             }
  106.         }
  107.         /// <summary>
  108.         /// 压缩字符串 返回编码好的字符
  109.         /// </summary>
  110.         /// <param name="uncompressedString">字符串</param>
  111.         public string Compress(string uncompressedString)
  112.         {
  113.             byte[] byteData = System.Text.Encoding.UTF8.GetBytes(uncompressedString);
  114.             MemoryStream ms = new MemoryStream();
  115.             //Stream s = new GZipOutputStream(ms);
  116.             //compressedStream = newGZipStream(targetStream, CompressionMode.Compress, true);
  117.             Stream s = new GZipStream(ms, CompressionMode.Compress, true);
  118.             s.Write(byteData, 0, byteData.Length);
  119.             s.Close();
  120.             byte[] compressData = (byte[])ms.ToArray();
  121.             ms.Flush();
  122.             ms.Close();
  123.             return System.Convert.ToBase64String(compressData, 0, compressData.Length);
  124.         }
  125.         /// <summary>
  126.         /// 压缩字符串 二进制
  127.         /// </summary>
  128.         /// <param name="uncompressedString">字符串</param>
  129.         public byte[] dbsCompress(string uncompressedString)
  130.         {
  131.             byte[] byteData = System.Text.Encoding.UTF8.GetBytes(uncompressedString);
  132.             MemoryStream ms = new MemoryStream();
  133.             //Stream s = new GZipOutputStream(ms);
  134.             //compressedStream = newGZipStream(targetStream, CompressionMode.Compress, true);
  135.             Stream s = new GZipStream(ms, CompressionMode.Compress, true);
  136.             s.Write(byteData, 0, byteData.Length);
  137.             s.Close();
  138.             byte[] compressData = (byte[])ms.ToArray();
  139.             ms.Flush();
  140.             ms.Close();
  141.             return compressData;
  142.         }
  143.         /// <summary>
  144.         /// 解压二进制 到字符串
  145.         /// </summary>
  146.         /// <param name="compressedString">字符串</param>
  147.         public string dbsDeCompress(byte[] byteInput)
  148.         {
  149.             try
  150.             {
  151.                 //string uncompressedString=string.Empty; 
  152.                 StringBuilder sb = new StringBuilder(409600);
  153.                 int totalLength = 0;
  154.                 //   byte[] byteInput = System.Convert.FromBase64String(compressedString);
  155.                 byte[] writeData = new byte[409600];
  156.                 //Stream s = new GZipInputStream(new MemoryStream(byteInput));
  157.                 //decompressedStream=newGZipStream(sourceStream,CompressionMode.Decompress,true);
  158.                 Stream s = new GZipStream(new MemoryStream(byteInput), CompressionMode.Decompress, true);
  159.                 while (true)
  160.                 {
  161.                     int size = s.Read(writeData, 0, writeData.Length);
  162.                     if (size > 0)
  163.                     {
  164.                         totalLength += size;
  165.                         sb.Append(System.Text.Encoding.UTF8.GetString(writeData, 0, size));
  166.                     }
  167.                     else
  168.                     {
  169.                         break;
  170.                     }
  171.                 }
  172.                 s.Flush();
  173.                 s.Close();
  174.                 return sb.ToString();
  175.             }
  176.             catch
  177.             {
  178.                 int u = 0;
  179.                 return "";
  180.             }
  181.         }
  182.         /// <summary>
  183.         /// 解压字符串 
  184.         /// </summary>
  185.         /// <param name="compressedString">字符串</param>
  186.         public string DeCompress(string compressedString)
  187.         {
  188.             //string uncompressedString=string.Empty; 
  189.             StringBuilder sb = new StringBuilder(409600);
  190.             int totalLength = 0;
  191.             byte[] byteInput = System.Convert.FromBase64String(compressedString);
  192.             byte[] writeData = new byte[4096];
  193.             //Stream s = new GZipInputStream(new MemoryStream(byteInput));
  194.             //decompressedStream=newGZipStream(sourceStream,CompressionMode.Decompress,true);
  195.             Stream s = new GZipStream(new MemoryStream(byteInput), CompressionMode.Decompress, true);
  196.             while (true)
  197.             {
  198.                 int size = s.Read(writeData, 0, writeData.Length);
  199.                 if (size > 0)
  200.                 {
  201.                     totalLength += size;
  202.                     sb.Append(System.Text.Encoding.UTF8.GetString(writeData, 0, size));
  203.                 }
  204.                 else
  205.                 {
  206.                     break;
  207.                 }
  208.             }
  209.             s.Flush();
  210.             s.Close();
  211.             return sb.ToString();
  212.         }
  213.         /// <summary>
  214.         ///   中文到BASE64 再 压缩
  215.         /// </summary>
  216.         /// <param name="CNCHINESEDATA">字符串</param>
  217.         public string CN2BASE64ZIP(String CNCHINESEDATA)
  218.         {
  219.             //中文到BASE64
  220.             String TmpM1 = CN2CODE(CNCHINESEDATA);
  221.             //BASE64到ZIP
  222.             string TmpM2 = Compress(TmpM1);
  223.             return TmpM2;
  224.         }
  225.         /// <summary>
  226.         ///数据先解压 然后到中文
  227.         /// </summary>
  228.         /// <param name="SOURCEDATA">字符串</param>
  229.         public string UNCN2BASE64ZIP(String SOURCEDATA)
  230.         {
  231.             string TmpN1 = DeCompress(SOURCEDATA);
  232.             string TmpN2 = CODE2CN(TmpN1);
  233.             return TmpN2;
  234.         }
  235.         /// <summary>
  236.         ///中文编码到BASE64// 1 先编码为GB2312 // 2 转换为byte // 3 编码为BASE64
  237.         /// </summary>
  238.         /// <param name="DataX">字符串</param>
  239.         public String CN2CODE(String DataX)
  240.         {
  241.             Encoding gbx = System.Text.Encoding.GetEncoding("gb2312");
  242.             Byte[] dataSV = gbx.GetBytes(DataX);
  243.             string base64String;
  244.             base64String =
  245.                    System.Convert.ToBase64String(dataSV,
  246.                                                  0,
  247.                                                  dataSV.Length);
  248.             return base64String;
  249.         }
  250.         /// <summary>
  251.         /// BASE64到中文// 1 解码为byte // 2 转换为2312
  252.         /// </summary>
  253.         /// <param name="DataX">字符串</param>
  254.         public String CODE2CN(String DataX)
  255.         {
  256.             try
  257.             {
  258.                 //Encoding gb = System.Text.Encoding.GetEncoding("Ansi");
  259.                 byte[] binaryData;
  260.                 binaryData =
  261.                             System.Convert.FromBase64String(DataX);
  262.                 Encoding gb = System.Text.Encoding.GetEncoding("gb2312");
  263.                 string base64String;
  264.                 base64String = gb.GetString(binaryData, 0, binaryData.Length);
  265.                 return base64String;
  266.             }
  267.             catch
  268.             {
  269.                 return DataX;
  270.             }
  271.         }
  272.         /// <summary>
  273.         /// New  中文 编码
  274.         /// </summary>
  275.         /// <param name="DataX">字符串</param>
  276.         public String New_CN2CODE(String DataX)
  277.         {
  278.             Encoding gbx = System.Text.Encoding.GetEncoding("gb2312");
  279.             Byte[] dataSV = gbx.GetBytes(DataX);
  280.             string base64String;
  281.             base64String =
  282.                    System.Convert.ToBase64String(dataSV,
  283.                                                  0,
  284.                                                  dataSV.Length);
  285.             return Base2NewBase(base64String);
  286.         }
  287.         /// <summary>
  288.         /// New 中文 解码
  289.         /// </summary>
  290.         /// <param name="DataX">字符串</param>
  291.         public String New_CODE2CN(String DataX)
  292.         {
  293.             if (DataX.IndexOf("\") != 0)  //不含有标志
  294.             {
  295.                 return DataX;
  296.             }
  297.             string myDataX = NewBase2Base(DataX);
  298.             try
  299.             {
  300.                 //Encoding gb = System.Text.Encoding.GetEncoding("Ansi");
  301.                 byte[] binaryData;
  302.                 binaryData =
  303.                             System.Convert.FromBase64String(myDataX);
  304.                 Encoding gb = System.Text.Encoding.GetEncoding("gb2312");
  305.                 string base64String;
  306.                 base64String = gb.GetString(binaryData, 0, binaryData.Length);
  307.                 return base64String;
  308.             }
  309.             catch
  310.             {
  311.                 return DataX;
  312.             }
  313.         }
  314.         
  315.         /// <summary>
  316.         /// 转义BASE64
  317.         /// </summary>
  318.         /// <param name="cdata">字符串</param> 
  319.         public string Base2NewBase(string cdata)
  320.         {
  321.             string myTmpcdata = cdata;                             //存放原始变量
  322.             Hashtable myHashtable = new Hashtable();
  323.             myHashtable = NewBaseDataList();
  324.             for (int i = 0; i < cdata.Length; i++)
  325.             {
  326.                 foreach (DictionaryEntry deX in myHashtable) //ht为一个Hashtable实例
  327.                 {
  328.                     if (myTmpcdata.IndexOf(deX.Key.ToString()) >= 0)
  329.                     {
  330.                         myTmpcdata = myTmpcdata.Replace(deX.Key.ToString(), deX.Value.ToString());
  331.                     }
  332.                 }
  333.             }
  334.             return "\" + myTmpcdata;  //前头加上标示
  335.         }
  336.         /// <summary>
  337.         /// 还原转义
  338.         /// </summary>
  339.         /// <param name="cdata">字符串</param> 
  340.         public string NewBase2Base(string cdata)
  341.         {
  342.             if (cdata.IndexOf("\") != 0)  //不含有标志
  343.             {
  344.                 return cdata;
  345.             }
  346.             string myTmpcdata = cdata.Substring(1, cdata.Length - 1);       //去掉前面的标示         //存放原始变量
  347.       
  348.             for (int i = 0; i < cdata.Length; i++)
  349.             {
  350.                 foreach (DictionaryEntry deX in myHashtable) //ht为一个Hashtable实例
  351.                 {
  352.                     if (myTmpcdata.IndexOf(deX.Value.ToString()) >= 0)
  353.                     {
  354.                         myTmpcdata = myTmpcdata.Replace(deX.Value.ToString(), deX.Key.ToString());
  355.                     }
  356.                 }
  357.             }
  358.             return myTmpcdata;
  359.         }
  360.         //转义  还原  定义  
  361.         private Hashtable NewBaseDataList()   //真时为 \A - a   假 a - \A
  362.         {
  363.             Hashtable NewBase64Predicates = new Hashtable();
  364.             NewBase64Predicates.Add("a", "\A");
  365.             NewBase64Predicates.Add("b", "\B");
  366.             NewBase64Predicates.Add("c", "\C");
  367.             NewBase64Predicates.Add("d", "\D");
  368.             NewBase64Predicates.Add("e", "\E");
  369.             NewBase64Predicates.Add("f", "\F");
  370.             NewBase64Predicates.Add("g", "\G");
  371.             NewBase64Predicates.Add("h", "\H");
  372.             NewBase64Predicates.Add("i", "\I");
  373.             NewBase64Predicates.Add("j", "\J");
  374.             NewBase64Predicates.Add("k", "\K");
  375.             NewBase64Predicates.Add("l", "\L");
  376.             NewBase64Predicates.Add("m", "\M");
  377.             NewBase64Predicates.Add("n", "\N");
  378.             NewBase64Predicates.Add("o", "\O");
  379.             NewBase64Predicates.Add("p", "\P");
  380.             NewBase64Predicates.Add("q", "\Q");
  381.             NewBase64Predicates.Add("r", "\R");
  382.             NewBase64Predicates.Add("s", "\S");
  383.             NewBase64Predicates.Add("t", "\T");
  384.             NewBase64Predicates.Add("u", "\U");
  385.             NewBase64Predicates.Add("v", "\V");
  386.             NewBase64Predicates.Add("w", "\W");
  387.             NewBase64Predicates.Add("x", "\X");
  388.             NewBase64Predicates.Add("y", "\Y");
  389.             NewBase64Predicates.Add("z", "\Z");
  390.             return NewBase64Predicates;
  391.         }
  392.         /// <summary>
  393.         /// 判断句子中是否含有中文
  394.         /// </summary>
  395.         /// <param name="words">字符串</param> 
  396.         public bool WordsIScn(string words)
  397.         {
  398.             string TmmP;
  399.             for (int i = 0; i < words.Length; i++)
  400.             {
  401.                 TmmP = words.Substring(i, 1);
  402.                 byte[] sarr = System.Text.Encoding.GetEncoding("gb2312").GetBytes(TmmP);
  403.                 if (sarr.Length == 2)
  404.                 {
  405.                     return true;
  406.                 }
  407.             }
  408.             return false;
  409.         }
  410.         /// <summary>
  411.         ///汉字和汉字序列编码
  412.         /// </summary>
  413.         /// <param name="GData">字符串</param> 
  414.         public string enSelectCode2(string GData)
  415.         {
  416.             if (GData.IndexOf(' ') < 0)
  417.             {
  418.                 return New_CN2CODE(GData);
  419.             }
  420.             string TTT = GData;
  421.             string[] TTT2 = TTT.Split(' ');
  422.             for (int i = 0; i < TTT2.Length; i++)
  423.             {
  424.                 if (WordsIScn(TTT2[i]))
  425.                 {
  426.                     TTT2[i] = New_CN2CODE(TTT2[i]);
  427.                 }
  428.             }
  429.             string TTT3 = "";
  430.             for (int i = 0; i < TTT2.Length; i++)
  431.             {
  432.                 TTT3 = TTT3 + TTT2[i] + " ";
  433.             }
  434.             return TTT3.Trim();
  435.         }
  436.         /// <summary>
  437.         ///是压缩过的字符串   如果是 则返回解压结果  如果不是 则返回原始值
  438.         /// </summary>
  439.         /// <param name="data">字符串</param> 
  440.         private string WordsISZIP(string data)
  441.         {
  442.             //压缩队列一般具有特征 以/打头 且可以正确解压
  443.             if (data.IndexOf("//") != 0) { return data; }
  444.             string KCBB = New_CODE2CN(data);
  445.             if (KCBB == data)   //如果没有正确解压 原样返回
  446.             {
  447.                 return data;
  448.             }
  449.             return KCBB;   //否则 返回解压结果
  450.         }
  451.   
  452.         /// <summary>
  453.         /// 去掉多余的换行
  454.         /// </summary>
  455.         /// <param name="dataN">字符串</param>
  456.         private string clearNN(string dataN)
  457.         {
  458.             string X = dataN;
  459.             while (X.IndexOf("rnrnrn") > 0)
  460.             {
  461.                 X = X.Replace("rnrnrn", "rn");
  462.             }
  463.             while (X.IndexOf("rnrn") > 0)
  464.             {
  465.                 X = X.Replace("rnrn", "rn");
  466.             }
  467.             while (X.IndexOf("nnn") > 0)
  468.             {
  469.                 X = X.Replace("nnn", "n");
  470.             }
  471.             while (X.IndexOf("nn") > 0)
  472.             {
  473.                 X = X.Replace("nn", "n");
  474.             }
  475.             return X;
  476.         }
  477.         /// <summary>
  478.         /// 编码2中文 错误时 补充== 
  479.         /// </summary>
  480.         /// <param name="DataX">字符串</param>
  481.         public string TTCODE2CN(String DataX)
  482.         {
  483.             int n = 0;
  484.             string mySource = DataX;
  485.             string myDt="";
  486.         TYR:
  487.             n = n + 1;
  488.                myDt = New_CODE2CN(DataX);
  489.                if (myDt!=DataX )
  490.                {
  491.                  return myDt ;
  492.                }
  493.                 if (n == 1)
  494.                 { DataX = DataX + "="; goto TYR; }
  495.                 if (n == 2)
  496.                 { DataX = DataX + "="; goto TYR; }
  497.                 return mySource;
  498.           }
  499.    
  500.         /// <summary>
  501.         /// 输入格式化: 把输入的汉字序列转变为 NewBSAE64 的 序列
  502.         /// </summary>
  503.         /// <param name="myData">字符串</param>
  504.         public string aInputDataC(string myData)
  505.         {
  506.             //不含有队列时直接返回编码结果
  507.             if (myData.IndexOf(' ') == -1) { return New_CN2CODE(myData); }
  508.             //去除多余空格
  509.             long L2 = 0;
  510.             L2 = myData.Length;
  511.             string[] myTmpData1 = myData.Split(' ');
  512.             string myTmpData3 = "";
  513.             for (int i = 0; i < myTmpData1.Length; i++)
  514.             {
  515.                 if (myTmpData1[i].Length > 0)
  516.                 {
  517.                     myTmpData1[i] = New_CN2CODE(myTmpData1[i]);
  518.                     myTmpData3 = myTmpData3 + " " + myTmpData1[i];
  519.                 }
  520.             }
  521.             return myTmpData3.Trim();
  522.         }
  523.         /// <summary>
  524.         /// 编码队列变换成汉字串
  525.         /// </summary>
  526.         /// <param name="DataY">字符串</param> 
  527.         public string aOutputDataC(string DataY)
  528.         {
  529.             if (DataY.IndexOf(" ") == -1)
  530.             {
  531.                 return New_CODE2CN(DataY);
  532.             }
  533.             string[] DataRE = DataY.Split(' ');
  534.             string DATAVBAK = "";
  535.             string TmpWEp = "";
  536.             for (int i = 0; i < DataRE.Length; i++)
  537.             {
  538.                 TmpWEp = New_CODE2CN(DataRE[i]);
  539.                 DATAVBAK = DATAVBAK + TmpWEp;
  540.             }
  541.             return DATAVBAK;
  542.         }
  543.         /// <summary>
  544.         ///  编码队列变换成汉字串 可控压缩
  545.         /// </summary>
  546.         /// <param name="DataZ">字符串</param> 
  547.         /// <param name="IsZip">是否是压缩标志</param> 
  548.         public string aOutputDataCrtL(string DataZ, string IsZip)
  549.         {
  550.             if (IsZip == "TT")
  551.             {
  552.                 string myTmpDE = "";
  553.                 if (DataZ.IndexOf(" ") >= 0)
  554.                 { myTmpDE = aOutputDataC(DataZ); }   //错误分词  含有空格 
  555.                 else
  556.                 { myTmpDE = New_CODE2CN(DataZ); }    //中文
  557.                 return myTmpDE;
  558.             }
  559.             else
  560.             {
  561.                 return DataZ;
  562.             }
  563.         }
  564.         /// <summary>
  565.         /// 去掉0的中文到编码
  566.         /// </summary>
  567.         /// <param name="data">中文数据</param>
  568.         /// <returns>编码数据</returns>
  569.         public string ssCN2CODE(string data)
  570.         {
  571.             string myAkcc = CN2CODE(data);
  572.             myAkcc = myAkcc.Replace("+","!");
  573.             myAkcc = myAkcc.Replace("=", "?");
  574.             return myAkcc;
  575.         }
  576.         /// <summary>
  577.         /// 去掉0的编码到中文
  578.         /// </summary>
  579.         /// <param name="data">编码数据</param>
  580.         /// <returns>中文数据</returns>
  581.         public string ssCODE2CN(string data)
  582.         {
  583.             data = data.Replace( "!","+");
  584.             data = data.Replace("?","=" );
  585.             string myAkcc = CODE2CN(data);
  586.             return myAkcc;
  587.         }
  588.         //"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  589.         /// <summary>
  590.         /// 目录编码  把路径名称转换为BASE64
  591.         /// </summary>
  592.         /// <param name="DataX">字符串</param>
  593.         public String DirCN2CODE(String DataX)
  594.         {
  595.             Encoding gbx = System.Text.Encoding.GetEncoding("gb2312");
  596.             Byte[] dataSV = gbx.GetBytes(DataX);
  597.             string base64String;
  598.             base64String =
  599.                    System.Convert.ToBase64String(dataSV,
  600.                                                  0,
  601.                                                  dataSV.Length);
  602.             string tmp99 = base64String;
  603.             tmp99 = tmp99.Replace('/','~');   //使之符合路径规范
  604.             return tmp99;
  605.         }
  606.         /// <summary>
  607.         /// 目录解码 把编码转换为路径名称 
  608.         /// </summary>
  609.         /// <param name="DataX">字符串</param>
  610.         public String DirCODE2CN(String DataX)
  611.         {
  612.             DataX = DataX.Replace('~','/');   //使之符合路径规范
  613.             try
  614.             {
  615.                 //Encoding gb = System.Text.Encoding.GetEncoding("Ansi");
  616.                 byte[] binaryData;
  617.                 binaryData =
  618.                             System.Convert.FromBase64String(DataX);
  619.                 Encoding gb = System.Text.Encoding.GetEncoding("gb2312");
  620.                 string base64String;
  621.                 base64String = gb.GetString(binaryData, 0, binaryData.Length);
  622.                 return base64String;
  623.             }
  624.             catch
  625.             {
  626.                 return DataX;
  627.             }
  628.         }
  629.     }
  630. }
  631. //MIME的编码方案于有许多种,Base64只是其中最常用的一种。Base64编码方案将要传送的信息转化为64个ASCII字符('A'-'Z','a'-'z','0'-'9','+','/')组成的字符串。