[Modify] Move it

This commit is contained in:
sta 2019-01-12 22:23:00 +09:00
parent 1ee35195b4
commit 2935c8e1cf

View File

@ -1030,6 +1030,29 @@ namespace WebSocketSharp.Net
: String.Empty; : String.Empty;
} }
public static string UrlEncode (string s)
{
return UrlEncode (s, Encoding.UTF8);
}
public static string UrlEncode (string s, Encoding encoding)
{
if (s == null)
throw new ArgumentNullException ("s");
var len = s.Length;
if (len == 0)
return s;
if (encoding == null)
encoding = Encoding.UTF8;
var bytes = new byte[encoding.GetMaxByteCount (len)];
var realLen = encoding.GetBytes (s, 0, len, bytes, 0);
return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen));
}
public static string UrlEncode (byte[] bytes, int offset, int count) public static string UrlEncode (byte[] bytes, int offset, int count)
{ {
if (bytes == null) if (bytes == null)
@ -1059,29 +1082,6 @@ namespace WebSocketSharp.Net
: String.Empty; : String.Empty;
} }
public static string UrlEncode (string s)
{
return UrlEncode (s, Encoding.UTF8);
}
public static string UrlEncode (string s, Encoding encoding)
{
if (s == null)
throw new ArgumentNullException ("s");
var len = s.Length;
if (len == 0)
return s;
if (encoding == null)
encoding = Encoding.UTF8;
var bytes = new byte[encoding.GetMaxByteCount (len)];
var realLen = encoding.GetBytes (s, 0, len, bytes, 0);
return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen));
}
public static byte[] UrlEncodeToBytes (byte[] bytes) public static byte[] UrlEncodeToBytes (byte[] bytes)
{ {
if (bytes == null) if (bytes == null)