Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

On the branch

svn path=/branches/mono-1-1-12/mcs/; revision=54732
  • Loading branch information...
commit 5c2e969ce7ad6473eabf8ab5fda756246268cc78 1 parent d0917ac
@migueldeicaza migueldeicaza authored
View
6 mcs/class/System.Web/System.Web/HttpUtility.cs
@@ -693,7 +693,11 @@ public static string UrlEncodeUnicode (string str)
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a' && c != '_') ||
(c > 'z')) {
- result.Append ("%u00");
+ if (c > 127)
+ result.Append ("%u00");
+ else
+ result.Append ("%");
+
idx = ((int) c) >> 4;
result.Append (hexChars [idx]);
idx = ((int) c) & 0x0F;
View
7 mcs/class/System.Web/Test/System.Web/HttpUtilityTest.cs
@@ -123,10 +123,13 @@ public void LooksLikeEntity ()
[Test]
public void UrlEncodeUnicodeTest ()
{
- string str = "schön";
+ string str = "sch" + (char) 0xf6 + "n";
- Assert.AreEqual (str, HttpUtility.UrlEncodeUnicode ("sch%00f6n"), "#1");
+ Assert.AreEqual ("sch%u00f6n", HttpUtility.UrlEncodeUnicode (str), "#1");
Assert.AreEqual ("abc", "abc", "#2");
+ Assert.AreEqual ("%26", HttpUtility.UrlEncodeUnicode ("&"), "#3");
+ Assert.AreEqual ("%7f", HttpUtility.UrlEncodeUnicode ("" + (char) 127), "#4");
+ Assert.AreEqual ("%u0080", HttpUtility.UrlEncodeUnicode ("" + (char) 128), "#5");
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.