Response SetCharEncoding Method C# API
Sets the character encoding that is used to decode the data contained in this Response.

Namespace: Facilita.Web
Assembly: clrWebBrowser (in clrWebBrowser.dll) Version: 9.5.5.77 (1.0.0.0)
Syntax

public void SetCharEncoding(
	string charEncoding
)

Parameters

charEncoding
Type: System String
The character encoding that should be used to decode the data in this Response.
Remarks

Usually, the character encoding will be determined automatically by:
  • looking for a charset in the response headers (e.g. Content-Type: text/html; charset=utf-8)
  • looking for a meta-tag in the HTML (e.g. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  • looking for a Byte Order Mark at the beginning of the response data
  • defaulting to ISO-8859-1 (latin-1) if none of the above could be found

Therefore, it is not usually necessary to call this method explicitly. However, if some of the information above is incorrect/missing, then you can override the encoding by calling this method.

Examples

The following example demonstrates setting the character encoding.
Response response = request.Send(); 

// Use the utf-8 character set to interpret the data in this response
response.SetCharEncoding("utf-8"); 

// The utf-8 character set will be used to decode the HTML and determine what the title is 
response.VerifyTitle("我是中国人", ActionType.ACT_NEXT_ITERATION);
See Also