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 6829891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:33:13+00:00 2026-05-26T22:33:13+00:00

I’m trying to convert wide char into multi-byte. It’s only on yje myfile part.

  • 0

I’m trying to convert wide char into multi-byte. It’s only on yje myfile part. The rest works fine.I can’t use wofstream because I am using ofstream in several places, so I am left with this.

void PrintBrowserInfo(IWebBrowser2 *pBrowser) {
BSTR bstr;
pBrowser->get_LocationURL(&bstr);
std::wstring wsURL;
wsURL = bstr;

size_t DSlashLoc = wsURL.find(L"://");
if (DSlashLoc != wsURL.npos)
  {
  wsURL.erase(wsURL.begin(), wsURL.begin() + DSlashLoc + 3);
  }
  DSlashLoc = wsURL.find(L"www.");
  if (DSlashLoc == 0)
{
wsURL.erase(wsURL.begin(), wsURL.begin() + 4);
}
DSlashLoc = wsURL.find(L"/");
if (DSlashLoc != wsURL.npos)
{
wsURL.erase(DSlashLoc);
}
wprintf(L"\n   URL: %s\n\n", wsURL.c_str());
char LogURL = WideCharToMultiByte( CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, NULL, 0,  NULL, NULL); 
    myfile << "\n   URL:" << LogURL;
    SysFreeString(bstr);
}

void EnumExplorers() {
CoInitialize(NULL);
SHDocVw::IShellWindowsPtr spSHWinds;
IDispatchPtr spDisp;
if (spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK) {
    long nCount = spSHWinds->GetCount();
    for (long i = 0; i < nCount; i++) {
        _variant_t va(i, VT_I4);
        spDisp = spSHWinds->Item(va);
        SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
        if (spBrowser != NULL) {
            PrintBrowserInfo((IWebBrowser2 *)spBrowser.GetInterfacePtr());
            spBrowser.Release();
        }
    }
} else {
    puts("Shell windows failed to initialise");
}

}

  • 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-26T22:33:14+00:00Added an answer on May 26, 2026 at 10:33 pm

    You’re using WideCharToMultiByte wrong. You need to pass it a string buffer to receive the converted string. Using NULL and 0 as parameters as you have done will return the required size of the result string.

    int length = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, NULL, 0,  NULL, NULL);
    std::string LogURL(length+1, 0);
    int result = WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsURL.c_str(), -1, &LogURL[0], length+1,  NULL, NULL);
    

    You should check result for a non-zero value to make sure the function worked correctly.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.