Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

HttpHeader: add 'GetCharset' function

  • Loading branch information...
commit 4d63ef9f90f0a0d1142894b26bc4a11af1b008c2 1 parent 389ce4d
@Karlson2k Karlson2k authored
Showing with 23 additions and 0 deletions.
  1. +22 −0 xbmc/utils/HttpHeader.cpp
  2. +1 −0  xbmc/utils/HttpHeader.h
View
22 xbmc/utils/HttpHeader.cpp
@@ -146,6 +146,28 @@ std::string CHttpHeader::GetMimeType(void) const
return strValue.substr(0, strValue.find(';'));
}
+std::string CHttpHeader::GetCharset(void) const
+{
+ std::string strValue(GetValueRaw("content-type"));
+ if (strValue.empty())
+ return strValue;
+
+ const size_t semicolonPos = strValue.find(';');
+ if (semicolonPos == std::string::npos)
+ return "";
+
+ StringUtils::ToUpper(strValue);
+ size_t posCharset;
+ if ((posCharset = strValue.find("; CHARSET=", semicolonPos)) != std::string::npos)
+ posCharset += 10;
+ else if ((posCharset = strValue.find(";CHARSET=", semicolonPos)) != std::string::npos)
+ posCharset += 9;
+ else
+ return "";
+
+ return strValue.substr(posCharset, strValue.find(';', posCharset) - posCharset);
+}
+
void CHttpHeader::Clear()
{
m_params.clear();
View
1  xbmc/utils/HttpHeader.h
@@ -43,6 +43,7 @@ class CHttpHeader
std::string GetHeader(void) const;
std::string GetMimeType(void) const;
+ std::string GetCharset(void) const;
std::string GetProtoLine() { return m_protoLine; }
inline bool IsHeaderDone(void) const
Please sign in to comment.
Something went wrong with that request. Please try again.