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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:13:10+00:00 2026-06-04T21:13:10+00:00

i am creating a program to read some files. while reading 1 of the

  • 0

i am creating a program to read some files.
while reading 1 of the files i encountered some umlaut characters in the file.
how should i read those characters
& store them in string?
currently i am using string::getline() which is unable to read these characters & the position of reading pointer is not incrementing.
the character is in a line preceded by some spaces.
so i am using ws to remove the spaces.
i used peek to understand the problem; while hovering over the peek o/p char VS2010 showed y with 2 dots on it. so i guess it is umlaut character.

  • 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-04T21:13:11+00:00Added an answer on June 4, 2026 at 9:13 pm

    If that is what you need – This code reads from file (UTF-8) text in German, prints it on console and saves in output file –

    #include <sstream>
    #include <iostream>
    #include <fstream>
    //To handle localized input -
    #include <windows.h>
    #include <conio.h>
    
    int main()
    {
    
    //read from file - 
        std::ifstream stream("c:\\temporary\\in.txt");
        std::string line;
    
        if (stream.is_open()) 
        { 
            std::getline(stream, line);
        }
    
    //print on console -
        if(!SetConsoleOutputCP(CP_UTF8)) { // 65001
            std::cerr << "Failed to set console output mode!\n";
            return 1;
        }
        HANDLE const consout = GetStdHandle(STD_OUTPUT_HANDLE);
        DWORD nNumberOfCharsWritten;
        const char* utf8 = line.c_str();
        if(!WriteConsoleA(consout, utf8, strlen(utf8), &nNumberOfCharsWritten, NULL)) {
            DWORD const err = GetLastError();
            std::cerr << "WriteConsole failed with << " << err << "!\n";
            return 1;
        }
    
    //write to file -
        std::fstream myfile;
        myfile.open("c:\\Temporary\\out.txt",std::ios::out);
        if (myfile.is_open()) 
        { 
    
            myfile << line <<"\n"<<std::endl;
        } 
        myfile.flush();
        myfile.close();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help for creating a File and String search engine. The program needs
I'm creating a program using C# (in ASP.NET environment) that makes an XML file.
When creating DLL files for a program that already exists, is it customary to
I have some configuration options for a program stored in a JSON file. I
I have a multi-threaded Delphi program creating multiple instance of some classes, and I
I have some code that effectively does this : File file = new File(C:\\Program
I have a C++ program that will read in data from a binary file
I'm creating a small program with some design patterns, and I'm trying to implement
I creating a program which send newsletter with a background image. It works fine
I'm creating a program that authenticates from a before it runs. I also want

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.