Probably similar to Issue 126. The UrlEncode method in OAuthBase.cs just
appends a hex encoding of the character. For multibyte chars you need to
hex encode each byte of the character instead.
My version of this method is (where NoEncodeChars is the list of characters
that do not require encoding):
public static string OAuthUrlEncode(string s)
{
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}
else
{
StringBuilder sb = new StringBuilder(s.Length);
for (int i = 0; i < s.Length; i++)
{
if (NoEncodeChars.IndexOf(s[i]) == -1)
{
// character needs encoding
byte[] characterBytes =
Encoding.UTF8.GetBytes(s[i].ToString());
for (int b = 0; b < characterBytes.Length; b++)
{
sb.AppendFormat(CultureInfo.InvariantCulture,
"%{0:X2}",
characterBytes[b]);
}
}
else
{
// character is allowed
sb.Append(s[i]);
}
}
return sb.ToString();
}
}
Original issue reported on code.google.com by robert.e...@gmail.com on 4 Apr 2010 at 4:30
Original issue reported on code.google.com by
robert.e...@gmail.com
on 4 Apr 2010 at 4:30