forked from DropNet/DropNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringExtensions.cs
More file actions
29 lines (27 loc) · 785 Bytes
/
Copy pathStringExtensions.cs
File metadata and controls
29 lines (27 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DropNet.Extensions
{
public static class StringExtensions
{
public static string UrlEncode(this string value)
{
value = Uri.EscapeDataString(value);
StringBuilder builder = new StringBuilder();
foreach (char ch in value)
{
if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~%".IndexOf(ch) != -1)
{
builder.Append(ch);
}
else
{
builder.Append('%' + string.Format("{0:X2}", (int)ch));
}
}
return builder.ToString();
}
}
}