Example #1
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++)
         {
             bool flag = input[i] == 32;
             if (flag)
             {
                 memoryStream.Write(space, 0, space.Length);
             }
             else
             {
                 bool flag2 = input[i] < 32 || input[i] > 126 || WWWTranscoder.ByteArrayContains(forbidden, input[i]);
                 if (flag2)
                 {
                     memoryStream.WriteByte(escapeChar);
                     memoryStream.Write(WWWTranscoder.Byte2Hex(input[i], uppercase ? WWWTranscoder.ucHexChars : WWWTranscoder.lcHexChars), 0, 2);
                 }
                 else
                 {
                     memoryStream.WriteByte(input[i]);
                 }
             }
         }
         result = memoryStream.ToArray();
     }
     return(result);
 }
 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);
 }
Example #3
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++)
         {
             bool flag = WWWTranscoder.ByteSubArrayEquals(input, i, space);
             if (flag)
             {
                 i += space.Length - 1;
                 memoryStream.WriteByte(32);
             }
             else
             {
                 bool flag2 = input[i] == escapeChar && i + 2 < input.Length;
                 if (flag2)
                 {
                     i++;
                     memoryStream.WriteByte(WWWTranscoder.Hex2Byte(input, i++));
                 }
                 else
                 {
                     memoryStream.WriteByte(input[i]);
                 }
             }
         }
         result = memoryStream.ToArray();
     }
     return(result);
 }
Example #4
0
 public static byte[] Decode(byte[] input, byte escapeChar, byte space)
 {
     using (MemoryStream memoryStream1 = new MemoryStream(input.Length))
     {
         for (int index = 0; index < input.Length; ++index)
         {
             if ((int)input[index] == (int)space)
             {
                 memoryStream1.WriteByte((byte)32);
             }
             else if ((int)input[index] == (int)escapeChar && index + 2 < input.Length)
             {
                 int          num1          = index + 1;
                 MemoryStream memoryStream2 = memoryStream1;
                 byte[]       b             = input;
                 int          offset        = num1;
                 int          num2          = 1;
                 index = offset + num2;
                 int num3 = (int)WWWTranscoder.Hex2Byte(b, offset);
                 memoryStream2.WriteByte((byte)num3);
             }
             else
             {
                 memoryStream1.WriteByte(input[index]);
             }
         }
         return(memoryStream1.ToArray());
     }
 }
Example #5
0
 /// <summary>
 ///   <para>Converts URL-friendly escape sequences back to normal text.</para>
 /// </summary>
 /// <param name="s">A string containing escaped characters.</param>
 /// <param name="e">The text encoding to use.</param>
 public static string UnEscapeURL(string s, [DefaultValue("System.Text.Encoding.UTF8")] Encoding e)
 {
     if (s == null)
     {
         return((string)null);
     }
     if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
     {
         return(s);
     }
     return(WWWTranscoder.URLDecode(s, e));
 }
Example #6
0
 public static string UnEscapeURL(string s, [UnityEngine.Internal.DefaultValue("System.Text.Encoding.UTF8")] Encoding e)
 {
     if (s == null)
     {
         return(null);
     }
     if ((s.IndexOf('%') == -1) && (s.IndexOf('+') == -1))
     {
         return(s);
     }
     return(WWWTranscoder.URLDecode(s, e));
 }
Example #7
0
 public static string EscapeURL(string s, [DefaultValue("System.Text.Encoding.UTF8")] Encoding e)
 {
     if (s == null)
     {
         return(null);
     }
     if (s == "")
     {
         return("");
     }
     if (e == null)
     {
         return(null);
     }
     return(WWWTranscoder.URLEncode(s, e));
 }
Example #8
0
 public static string EscapeURL(string s, [UnityEngine.Internal.DefaultValue("System.Text.Encoding.UTF8")] Encoding e)
 {
     if (s == null)
     {
         return(null);
     }
     if (s == string.Empty)
     {
         return(string.Empty);
     }
     if (e == null)
     {
         return(null);
     }
     return(WWWTranscoder.URLEncode(s, e));
 }
Example #9
0
        public static string UnEscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                result = s;
            }
            else
            {
                result = WWWTranscoder.URLDecode(s, e);
            }
            return(result);
        }
Example #10
0
        public static string UnEscapeURL(string s, [UnityEngine.Internal.DefaultValue("System.Text.Encoding.UTF8")] Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                result = s;
            }
            else
            {
                result = WWWTranscoder.URLDecode(s, e);
            }
            return(result);
        }
Example #11
0
        public static string EscapeURL(string s, [UnityEngine.Internal.DefaultValue("System.Text.Encoding.UTF8")] Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s == "")
            {
                result = "";
            }
            else if (e == null)
            {
                result = null;
            }
            else
            {
                result = WWWTranscoder.URLEncode(s, e);
            }
            return(result);
        }
Example #12
0
        public static string EscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s == "")
            {
                result = "";
            }
            else if (e == null)
            {
                result = null;
            }
            else
            {
                result = WWWTranscoder.URLEncode(s, e);
            }
            return(result);
        }
Example #13
0
 public static byte[] Encode(byte[] input, byte escapeChar, byte space, byte[] forbidden, bool uppercase)
 {
     using (MemoryStream memoryStream = new MemoryStream(input.Length * 2))
     {
         for (int index = 0; index < input.Length; ++index)
         {
             if ((int)input[index] == 32)
             {
                 memoryStream.WriteByte(space);
             }
             else if ((int)input[index] < 32 || (int)input[index] > 126 || WWWTranscoder.ByteArrayContains(forbidden, input[index]))
             {
                 memoryStream.WriteByte(escapeChar);
                 memoryStream.Write(WWWTranscoder.Byte2Hex(input[index], !uppercase ? WWWTranscoder.lcHexChars : WWWTranscoder.ucHexChars), 0, 2);
             }
             else
             {
                 memoryStream.WriteByte(input[index]);
             }
         }
         return(memoryStream.ToArray());
     }
 }
Example #14
0
 public static byte[] URLEncode(byte[] toEncode)
 {
     return(WWWTranscoder.Encode(toEncode, WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace, WWWTranscoder.urlForbidden, false));
 }
Example #15
0
 public static string URLEncode(string toEncode, Encoding e)
 {
     byte[] array = WWWTranscoder.Encode(e.GetBytes(toEncode), WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace, WWWTranscoder.urlForbidden, false);
     return(WWWForm.DefaultEncoding.GetString(array, 0, array.Length));
 }
Example #16
0
 public static string URLEncode(string toEncode)
 {
     return(WWWTranscoder.URLEncode(toEncode, Encoding.UTF8));
 }
Example #17
0
 public static bool SevenBitClean(string s, Encoding e)
 {
     return(WWWTranscoder.SevenBitClean(e.GetBytes(s)));
 }
Example #18
0
 public static bool SevenBitClean(string s)
 {
     return(WWWTranscoder.SevenBitClean(s, Encoding.UTF8));
 }
        public static string QPEncode(string toEncode)
        {
            Encoding uTF = Encoding.UTF8;

            return(WWWTranscoder.QPEncode(toEncode, uTF));
        }
 public static string URLDecode(string toEncode, [DefaultValue("Encoding.UTF8")] Encoding e)
 {
     byte[] array = WWWTranscoder.Decode(WWW.DefaultEncoding.GetBytes(toEncode), WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace);
     return(e.GetString(array, 0, array.Length));
 }
Example #21
0
 public static string DataDecode(string toDecode)
 {
     return(WWWTranscoder.DataDecode(toDecode, Encoding.UTF8));
 }
Example #22
0
 public static string URLEncode(string toEncode, [DefaultValue("Encoding.UTF8")] Encoding e)
 {
     byte[] bytes = WWWTranscoder.Encode(e.GetBytes(toEncode), WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace, WWWTranscoder.urlForbidden, false);
     return(WWW.DefaultEncoding.GetString(bytes, 0, bytes.Length));
 }
        public static bool SevenBitClean(string s)
        {
            Encoding uTF = Encoding.UTF8;

            return(WWWTranscoder.SevenBitClean(s, uTF));
        }
Example #24
0
 public static byte[] QPEncode(byte[] toEncode)
 {
     return(WWWTranscoder.Encode(toEncode, WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace, WWWTranscoder.qpForbidden, true));
 }
 public static string QPEncode(string toEncode, [DefaultValue("Encoding.UTF8")] Encoding e)
 {
     byte[] array = WWWTranscoder.Encode(e.GetBytes(toEncode), WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace, WWWTranscoder.qpForbidden, true);
     return(WWW.DefaultEncoding.GetString(array, 0, array.Length));
 }
Example #26
0
 public static byte[] QPDecode(byte[] toEncode)
 {
     return(WWWTranscoder.Decode(toEncode, WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace));
 }
Example #27
0
 public static byte[] DataDecode(byte[] toDecode)
 {
     return(WWWTranscoder.Decode(toDecode, WWWTranscoder.urlEscapeChar, WWWTranscoder.dataSpace));
 }
 public static bool SevenBitClean(string s, [DefaultValue("Encoding.UTF8")] Encoding e)
 {
     return(WWWTranscoder.SevenBitClean(e.GetBytes(s)));
 }
Example #29
0
 public static byte[] URLDecode(byte[] toEncode)
 {
     return(WWWTranscoder.Decode(toEncode, WWWTranscoder.urlEscapeChar, WWWTranscoder.urlSpace));
 }
Example #30
0
 public static string QPDecode(string toEncode, Encoding e)
 {
     byte[] array = WWWTranscoder.Decode(WWWForm.DefaultEncoding.GetBytes(toEncode), WWWTranscoder.qpEscapeChar, WWWTranscoder.qpSpace);
     return(e.GetString(array, 0, array.Length));
 }