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

  • Home
  • SEARCH
  • 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 9015399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:44:29+00:00 2026-06-16T03:44:29+00:00

My program reads text from a file and puts it in combo box. When

  • 0

My program reads text from a file and puts it in combo box.
When the file contains text with english characters everything works fine.
When it contains some polish letters, they are replacing with strange characters.
The file encoding is UTF-8 (without BOM).

myCombo = CreateWindowExW(WS_EX_CLIENTEDGE, (LPCWSTR)L"COMBOBOX", NULL,
                             WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,
                             a, b, c, d,
                             hwnd, (HMENU)ID_COMBO, hThisInstance, NULL);

wstring foo;
wifstream bar("theTextFile.txt");
getline(bar, foo);
SendMessageW(myCombo, CB_ADDSTRING, (WPARAM)0, (LPARAM)(foo.c_str()));

What can I do to make my program showing correct national letters?

PS. Sorry for my poor English 🙂

  • 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-06-16T03:44:31+00:00Added an answer on June 16, 2026 at 3:44 am

    wifstream won’t read UTF-8 text on Windows by default. The codecvt facet in the stream’s locale is what converts from the bytes in the file into wchar_t, so you need to set this such that it will do the conversion to wchar_t you want.

    Something like this:

    #include <fstream>
    #include <string>
    
    #include <locale>  // std::locale
    #include <codecvt> // std::codecvt_utf8_utf16
    #include <memory>  // std::unique_ptr
    
    #include <Windows.h> // WriteConsoleW
    
    int main(int argc, const char * argv[])
    {
        std::wstring foo;
        std::wifstream bar("theTextFile.txt");
    
        typedef std::codecvt_utf8_utf16<wchar_t, 0x10FFFF, std::consume_header> codecvt;
        std::unique_ptr<codecvt> ptr(new codecvt);
        std::locale utf8_locale((std::locale()), ptr.get());
        ptr.release();
        bar.imbue(utf8_locale);
    
        std::getline(bar, foo);
    
        DWORD n;
        WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), foo.c_str(), foo.size(), &n, NULL);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program that reads some text from a file, line by
I have a small Java program that reads list of IPs from text file
I have a C program that reads from a txt file. The text file
It's a program that reads student data from a text file and displys it
My program reads lines from a plain text file w/ lines formatted: <integer>;<integer>%n ,
I have a Java program that reads lines from text file. I want to
Write a program which reads a text file called input.txt which contains an arbitrary
I'm trying to write a little C# program that reads from a text file
I have a program which reads commands from a text file for example, the
Currently my program reads images and text in a record from an xml file,

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.