software22
asked on
Get Encoding From byte array
In my app, HTML is downloaded from server an stream to a byte array. But I don't know how to detect its encoding. Encoding of these html can be iso8859-1 or UTF-8.
My code :
byte[] objDataArray = ...
System.Text.UTF8Encoding objEncoding = new System.Text.UTF8Encoding() ;
string strData = objEncoding.GetString(objD ataArray);
-- > if encoding of html is iso8859-1, strData will not correct
Please help me !
My code :
byte[] objDataArray = ...
System.Text.UTF8Encoding objEncoding = new System.Text.UTF8Encoding()
string strData = objEncoding.GetString(objD
-- > if encoding of html is iso8859-1, strData will not correct
Please help me !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If there is no preamble you can just guess. May be there is a field in the http header indicating the encoding.