Merge pull request #778 from cmorris98/master
[mono.git] / mcs / class / System / System.Net / WebUtility.cs
1 //\r
2 // System.Net.WebUtility\r
3 //\r
4 // Authors: Mike Kestner  <mkestner@novell.com>\r
5 //          Marek Safar (marek.safar@gmail.com)\r
6 //\r
7 // Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)\r
8 //\r
9 // Permission is hereby granted, free of charge, to any person obtaining\r
10 // a copy of this software and associated documentation files (the\r
11 // "Software"), to deal in the Software without restriction, including\r
12 // without limitation the rights to use, copy, modify, merge, publish,\r
13 // distribute, sublicense, and/or sell copies of the Software, and to\r
14 // permit persons to whom the Software is furnished to do so, subject to\r
15 // the following conditions:\r
16 // \r
17 // The above copyright notice and this permission notice shall be\r
18 // included in all copies or substantial portions of the Software.\r
19 // \r
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
27 //\r
28 \r
29 #if NET_4_0\r
30 using System;\r
31 using System.IO;\r
32 using System.Runtime.Serialization;\r
33 \r
34 namespace System.Net \r
35 {\r
36 \r
37         public static class WebUtility \r
38         {\r
39                 \r
40                 public static string HtmlDecode (string value)\r
41                 {\r
42                         if (string.IsNullOrEmpty (value))\r
43                                 return value;\r
44 \r
45                         return HttpUtility.HtmlDecode (value);\r
46                 }\r
47                 \r
48                 public static void HtmlDecode (string value, TextWriter output)\r
49                 {\r
50                         if (output == null)\r
51                                 throw new ArgumentNullException ("output");\r
52 \r
53                         output.Write (HtmlDecode (value));\r
54                 }\r
55                 \r
56                 public static string HtmlEncode (string value)\r
57                 {\r
58                         return HttpUtility.HtmlEncode (value);\r
59                 }\r
60                 \r
61                 public static void HtmlEncode (string value, TextWriter output)\r
62                 {\r
63                         if (output == null)\r
64                                 throw new ArgumentNullException ("output");\r
65 \r
66                         output.Write (HtmlEncode (value));\r
67                 }\r
68                 \r
69                 public static string UrlDecode (string encodedValue)\r
70                 {\r
71                         return HttpUtility.UrlDecode (encodedValue);\r
72                 }\r
73                 \r
74                 public static byte[] UrlDecodeToBytes (\r
75                         byte[] encodedValue, int offset, int count)\r
76                 {\r
77                         return HttpUtility.UrlDecodeToBytes (encodedValue, offset, count);\r
78                 }\r
79                 \r
80                 public static string UrlEncode (string value)\r
81                 {\r
82                         return HttpUtility.UrlEncode (value);\r
83                 }\r
84                 \r
85                 public static byte[] UrlEncodeToBytes (\r
86                         byte[] value, int offset, int count)\r
87                 {\r
88                         return HttpUtility.UrlEncodeToBytes (value, offset, count);\r
89                 }\r
90         }\r
91 }\r
92 #endif\r