user38329
user38329

Reputation: 719

C++, web browser control: cannot change encoding/charset

There's a document I'm displaying in a web browser ActiveX control hosted in a C++ app. This document has a META tag that specifies incorrect charset, so the output is funny. I know the correct encoding and want to change it programmatically to fix that. But whatever I try, the encoding remains unchanged.

I alredy tried, in various combinations and flavors:

The control demonstrates remarkable persistence in preserving the incorrect encoding. What are my other options? I can't manipulate the source of the document being loaded.

Upvotes: 1

Views: 1187

Answers (3)

Hervema
Hervema

Reputation: 11

try to put the designMode property "On".

Upvotes: 1

user38329
user38329

Reputation: 719

Here's what eventually worked:

In the handler of the "NavigateComplete2" browser event,

  • the charset is modified using the charset property,
  • then the META tag is thrown away by setting its outerHTML to empty string,
  • and then the control is refreshed.

Modifying the order of these actions, or omitting a step, will render the entire operation void. MSHTML is picky.

Upvotes: 0

egrunin
egrunin

Reputation: 25083

According to this, it should work if you call IWebBrowser->Refresh() after calling IHTMLDocument2->put_charset().

Upvotes: 0

Related Questions