[Modify] Polish it
This commit is contained in:
parent
1bbac5e3da
commit
bb44ff169c
@ -1170,6 +1170,34 @@ namespace WebSocketSharp.Net
|
|||||||
: bytes;
|
: bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count)
|
||||||
|
{
|
||||||
|
if (bytes == null) {
|
||||||
|
if (count != 0)
|
||||||
|
throw new ArgumentNullException ("bytes");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var len = bytes.Length;
|
||||||
|
if (len == 0) {
|
||||||
|
if (offset != 0 || count != 0)
|
||||||
|
throw new ArgumentException ("An empty byte array.", "bytes");
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset < 0 || offset >= len)
|
||||||
|
throw new ArgumentOutOfRangeException ("offset");
|
||||||
|
|
||||||
|
if (count < 0 || count > len - offset)
|
||||||
|
throw new ArgumentOutOfRangeException ("count");
|
||||||
|
|
||||||
|
return count > 0
|
||||||
|
? InternalUrlEncodeToBytes (bytes, offset, count)
|
||||||
|
: new byte[0];
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] UrlEncodeToBytes (string s)
|
public static byte[] UrlEncodeToBytes (string s)
|
||||||
{
|
{
|
||||||
return UrlEncodeToBytes (s, Encoding.UTF8);
|
return UrlEncodeToBytes (s, Encoding.UTF8);
|
||||||
@ -1187,24 +1215,6 @@ namespace WebSocketSharp.Net
|
|||||||
return InternalUrlEncodeToBytes (bytes, 0, bytes.Length);
|
return InternalUrlEncodeToBytes (bytes, 0, bytes.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
if (bytes == null || (len = bytes.Length) == 0)
|
|
||||||
return bytes;
|
|
||||||
|
|
||||||
if (count == 0)
|
|
||||||
return new byte[0];
|
|
||||||
|
|
||||||
if (offset < 0 || offset >= len)
|
|
||||||
throw new ArgumentOutOfRangeException ("offset");
|
|
||||||
|
|
||||||
if (count < 0 || count > len - offset)
|
|
||||||
throw new ArgumentOutOfRangeException ("count");
|
|
||||||
|
|
||||||
return InternalUrlEncodeToBytes (bytes, offset, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string UrlEncodeUnicode (string s)
|
public static string UrlEncodeUnicode (string s)
|
||||||
{
|
{
|
||||||
if (s == null || s.Length == 0)
|
if (s == null || s.Length == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user