Link to home
Start Free TrialLog in
Avatar of software22
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(objDataArray);

-- > if encoding of html is iso8859-1, strData will not correct

Please help me !
ASKER CERTIFIED SOLUTION
Avatar of xmstr
xmstr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If there is no preamble you can just guess. May be there is a field in the http header indicating the encoding.