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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:11:19+00:00 2026-05-16T02:11:19+00:00

I have the lovely functions from my previous question , which work fine if

  • 0

I have the lovely functions from my previous question, which work fine if I do this:

wstring temp;
wcin >> temp;

string whatever( toUTF8(getSomeWString()) );

// store whatever, copy, but do not use it as UTF8 (see below)

wcout << toUTF16(whatever) << endl;

The original form is reproduced, but the in between form often contains extra characters. If I enter for example àçé as the input, and add a cout << whatever statement, i’ll get ┬à┬ç┬é as output.

Can I still use this string to compare to others, procured from an ASCII source? Or asked differently: if I would output ┬à┬ç┬é through the UTF8 cout in linux, would it read àçé? Is the byte content of a string àçé, read in UTF8 linux by cin, exactly the same as what the Win32 API gets me?

Thanks!

PS: the reason I’m asking is because I need to use the string a lot to compare to other read values (comparing and concatenating…).

  • 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-16T02:11:19+00:00Added an answer on May 16, 2026 at 2:11 am

    Let’s start by me saying that it appears that there is simply no way to output UTF-8 text to the console in Windows via cout (assuming you compile with Visual Studio).
    What you can do however for your tests is to output your UTF-8 text via the Win32 API fn WriteConsoleA:

    if(!SetConsoleOutputCP(CP_UTF8)) { // 65001
        cerr << "Failed to set console output mode!\n";
        return 1;
    }
    HANDLE const consout = GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD nNumberOfCharsWritten;
    const char* utf8 = "Umlaut AE = \xC3\x84 / ue = \xC3\xBC \n";
    if(!WriteConsoleA(consout, utf8, strlen(utf8), &nNumberOfCharsWritten, NULL)) {
        DWORD const err = GetLastError();
        cerr << "WriteConsole failed with << " << err << "!\n";
        return 1;
    }
    

    This should output:
    Umlaut AE = Ä / ue = ü if you set your console (cmd.exe) to use the Lucida Console font.

    As for your question (taken from your comment) if

    a win23 API converted string is the
    same as a raw UTF8 (linux) string

    I will say yes: Given a Unicode character sequence, it’s UTF-16 (Windows wchar_t) representation converted to a UTF-8 (char) representation via the WideCharToMultiByte function will always yield the same byte sequence.

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

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
I'm using the wonderfully lightweight jQuery minitabs plugin from: http://code.google.com/p/minitabs/ which is a lovely
i have done an Accordion style jQuery function which works lovely, but would like
I have the code below, which works lovely and does EXACTLY what I want
So far i have got the code below which works lovely when trying an
I have this lovely javascript bookmarklet... javascript:var nam=blablabla&amp;name; var els=document.getElementsByName(nam); if(els.length == 0) alert(nam);
So I have this grid. It's a very nice grid. Lovely, really. Except when
I have a chained dropdown box that pieces together a download string from a
I have a site http://www.special4you.co.uk and has a animation nav made from balloons. This
I am trying to add a footer in HTML, and I have this lovely

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.