internal static void ParseContentType(String contentType,
out String value,
out String charset)
{
charset = null;
if (contentType == null)
{
value = null;
return;
}
String[] parts = contentType.Split(s_semicolonSeparator);
// the actual content-type value is always first
value = parts[0];
// examine name value pairs and look for charset
if (parts.Length > 0)
{
foreach (String part in parts)
{
int index = part.IndexOf('=');
if (index != -1)
{
String key = part.Substring(0, index).Trim();
if (String.Compare(key, "charset", StringComparison.OrdinalIgnoreCase) == 0)
{
if ((index + 1) < part.Length)
{
// we had to make sure there is something after the
// equals sign.
charset = part.Substring(index + 1);
}
else
{
charset = null;
}
return;
}
}
} // foreach
}
} // ParseContentType