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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:26:17+00:00 2026-06-02T17:26:17+00:00

I have one file that is encoded in ANSI format (showing in Notepad++ as

  • 0

I have one file that is encoded in ANSI format (showing in Notepad++ as Encoded in ANSI) and it also shows the special characters (degree celcius,pound etc.) and while reading i want to convert all the characters to unicode.

How can i convert ANSI to Unicode in C/C++ or Qt ?

  • 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-02T17:26:19+00:00Added an answer on June 2, 2026 at 5:26 pm

    My Qt is still very rusty, but something along the following lines:

    QFile inFile("foo.txt");
    if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text))
        return;
    
    QFile outFile("foo.out.txt");
    if (!outFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
        return;
    
    QTextStream in(&inFile);
    QTextStream out(&outFile);
    out.setCodec("UTF-8");
    
    while (!in.atEnd()) {
        QString line = in.readLine();
        out << line;
    }
    

    Pieced together from the documentation of QFile and QTextStream, both of which include examples for reading and writing files. The default for QTextStream is to use the legacy encoding, so we only need to set an explicit encoding on the output QTextStream.

    If the file isn’t too large you could probably also use

    out << in.readAll();
    

    instead of the loop over the lines. The loop especially might add a trailing line break to the output file (although the docs aren’t very clear on that).

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

Sidebar

Related Questions

I have created one file that contains (degree celcius character) and other character that
I have problem with session in cakephp.I have one file chat.php that is in
I have one method that opens a file and passes off to another function
I have one requirement that i have to place the log file in the
I have generated an XML file that and one of the nodes contains data
I have a batch file that is located on one machine that I am
I have a text file that has item numbers in it (one per line).
I have an XML file that I'm trying to parse with Linq-to-XML. One of
I have a program that reads one image file, makes some changes on that
I have a fairly straightforward WCF service that performs one-way file synchronization for a

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.