Пример #1
0
 public static byte[] Decode(byte[] input, byte escapeChar, byte space)
 {
     byte[] result;
     using (MemoryStream memoryStream = new MemoryStream(input.Length))
     {
         for (int i = 0; i < input.Length; i++)
         {
             if (input[i] == space)
             {
                 memoryStream.WriteByte(32);
             }
             else if (input[i] == escapeChar && i + 2 < input.Length)
             {
                 i++;
                 memoryStream.WriteByte(WWWTranscoder.Hex2Byte(input, i++));
             }
             else
             {
                 memoryStream.WriteByte(input[i]);
             }
         }
         result = memoryStream.ToArray();
     }
     return(result);
 }
Пример #2
0
 public static byte[] Encode(byte[] input, byte escapeChar, byte space, byte[] forbidden, bool uppercase)
 {
     byte[] result;
     using (MemoryStream memoryStream = new MemoryStream(input.Length * 2))
     {
         for (int i = 0; i < input.Length; i++)
         {
             if (input[i] == 32)
             {
                 memoryStream.WriteByte(space);
             }
             else if (input[i] < 32 || input[i] > 126 || WWWTranscoder.ByteArrayContains(forbidden, input[i]))
             {
                 memoryStream.WriteByte(escapeChar);
                 memoryStream.Write(WWWTranscoder.Byte2Hex(input[i], (!uppercase) ? WWWTranscoder.lcHexChars : WWWTranscoder.ucHexChars), 0, 2);
             }
             else
             {
                 memoryStream.WriteByte(input[i]);
             }
         }
         result = memoryStream.ToArray();
     }
     return(result);
 }
Пример #3
0
 public static byte[] QPEncode(byte[] toEncode)
 {
     return(WWWTranscoder.Encode(toEncode, WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace, WWWTranscoder.qpForbidden, true));
 }
Пример #4
0
 public static string QPEncode(string toEncode, Encoding e)
 {
     byte[] array = WWWTranscoder.Encode(e.GetBytes(toEncode), WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace, WWWTranscoder.qpForbidden, true);
     return(Encoding.UTF8.GetString(array, 0, array.Length));
 }
Пример #5
0
        public static string QPEncode(string toEncode)
        {
            Encoding uTF = Encoding.UTF8;

            return(WWWTranscoder.QPEncode(toEncode, uTF));
        }
Пример #6
0
 public static byte[] URLEncode(byte[] toEncode)
 {
     return(WWWTranscoder.Encode(toEncode, WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace, WWWTranscoder.urlForbidden, false));
 }
Пример #7
0
 public static string URLEncode(string toEncode, Encoding e)
 {
     byte[] array = WWWTranscoder.Encode(e.GetBytes(toEncode), WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace, WWWTranscoder.urlForbidden, false);
     return(Encoding.UTF8.GetString(array, 0, array.Length));
 }
Пример #8
0
 public static bool SevenBitClean(string s, Encoding e)
 {
     return(WWWTranscoder.SevenBitClean(e.GetBytes(s)));
 }
Пример #9
0
        public static bool SevenBitClean(string s)
        {
            Encoding uTF = Encoding.UTF8;

            return(WWWTranscoder.SevenBitClean(s, uTF));
        }
Пример #10
0
 public static byte[] QPDecode(byte[] toEncode)
 {
     return(WWWTranscoder.Decode(toEncode, WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace));
 }
Пример #11
0
 public static byte[] URLDecode(byte[] toEncode)
 {
     return(WWWTranscoder.Decode(toEncode, WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace));
 }