Exemplo n.º 1
0
 public static string UrlEncodeUnicode(string str)
 {
     if (str != null)
     {
         return(UrlUtility.UrlEncodeUnicodeStringToStringInternal(str, false));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
            private string ToString(bool urlencoded, IDictionary excludeKeys)
            {
                int n = Count;

                if (n == 0)
                {
                    return(string.Empty);
                }

                StringBuilder s = new StringBuilder();
                string        key, keyPrefix, item;

                for (int i = 0; i < n; i++)
                {
                    key = GetKey(i);

                    if (excludeKeys != null && key != null && excludeKeys[key] != null)
                    {
                        continue;
                    }
                    if (urlencoded)
                    {
                        key = UrlUtility.UrlEncodeUnicodeStringToStringInternal(key, false);
                    }
                    keyPrefix = (!string.IsNullOrEmpty(key)) ? (key + "=") : string.Empty;

                    ArrayList values    = (ArrayList)BaseGet(i);
                    int       numValues = (values != null) ? values.Count : 0;

                    if (s.Length > 0)
                    {
                        s.Append('&');
                    }

                    if (numValues == 1)
                    {
                        s.Append(keyPrefix);
                        item = (string)values[0];
                        if (urlencoded)
                        {
                            item = UrlUtility.UrlEncodeUnicodeStringToStringInternal(item, false);
                        }
                        s.Append(item);
                    }
                    else if (numValues == 0)
                    {
                        s.Append(keyPrefix);
                    }
                    else
                    {
                        for (int j = 0; j < numValues; j++)
                        {
                            if (j > 0)
                            {
                                s.Append('&');
                            }
                            s.Append(keyPrefix);
                            item = (string)values[j];
                            if (urlencoded)
                            {
                                item = UrlUtility.UrlEncodeUnicodeStringToStringInternal(item, false);
                            }
                            s.Append(item);
                        }
                    }
                }

                return(s.ToString());
            }