Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4320686
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:39:39+00:00 2026-05-21T08:39:39+00:00

A web page is loaded from the Internet in a windowless IHTMLDocument for future

  • 0

A web page is loaded from the Internet in a windowless IHTMLDocument for future tweaking of the DOM. Everything is fine, except the charset is wrong: regardless of the charset advertised in the webpage in the META section, the charset property of the IHTMLDocument always turns out “Windows-1251” immediately after the document is loaded.

When I later write the modified document out, the file is unreadable due to encoding mismatch: the text is in original encoding, whereas the META charset tag in the new document is “Windows-1251”.

Here’s the code I use to load the document (error handling and cleanup omitted).

    IHTMLDocument2* pDoc = NULL;
    CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, 
            IID_IHTMLDocument2, (void**)&pDoc);

    IMoniker* pIMoniker = NULL;
    CreateURLMonikerEx(NULL, path.c_str(), &pIMoniker, URL_MK_UNIFORM);

    IPersistMoniker* pPMk= NULL;
    pDoc->QueryInterface(IID_IPersistMoniker, (void **)&pPMk);

    IBindCtx *pBCtx = NULL;
    CreateBindCtx(0, &pBCtx);

    pPMk->Load(FALSE, pIMoniker, pBCtx, STGM_READ|STGM_SHARE_EXCLUSIVE);

Why is the encoding wrong, and how do I make it right? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:39:39+00:00Added an answer on May 21, 2026 at 8:39 am

    Problem resolved by putting the IHTMLDocument in design mode before loading:

    hr = pDoc->put_designMode(L"On");   
    

    The encoding is right after this modification. (But why?..)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

web page : http://sideradesign.com/eco-art/gallery/ This code works fine in all brwosers except IE8 (haven't
How can I retrieve the Javascript function value from a web page loaded withing
I have a web page. When this web page is loaded, I want to
I have a web page that is intended to be loaded on a person's
How can I prevent users from pressing my web-page buttons before the page is
I want to extract all the dynamic javascript functions from a web page, with
Short version : How can an MFC ActiveX control loaded into a web page
I want to transfer local resources to a page, loaded from remote server. I
I'm writing a web page that has a from field that allows a user
My web page sits in a DIV that is 960px wide, I center this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.