Click here to Skip to main content
15,885,767 members
Articles / Desktop Programming / QT
Tip/Trick

Decode and encode text files using Qt 5

Rate me:
Please Sign up or sign in to vote.
3.54/5 (4 votes)
3 Sep 2013CPOL 18K   621   1   2
EncodeText is a small program that can decode and encode text files using any of the codecs supported by Qt

Introduction

EncodeText is a small program that can decode and encode text files using any of the codecs supported by Qt. The source is a single cpp-file called EncodeText.cpp. The project file used with qmake is called EncodeText.pro. In addition, I have attached a few batch files that illustrates how to use the program.

Background

When going from Qt 4 to Qt 5, I realized that Qt 5 wants UTF-8 source files. Since I didn't have any converter that could easily convert many files in one operation, I decided to create one using Qt 5.

Using the code

I have only tested the program on Windows 7 using Qt Creator, Qt 5.1.1 and the MSVC 2012 compiler. However, I think that the same source will work on the other desktop platforms supported by Qt. If not, please let me know.

Points of Interest

The attached batch files using the %* argument allows you to convert many files in one operation. They even works with file names that include Unicode characters above codepoint U+FF.

History

  • 2013-09-03: Initial edition

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Rainpower
Norway Norway
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 3 Pin
John M. Drescher4-Sep-13 1:32
John M. Drescher4-Sep-13 1:32 
GeneralRe: My vote of 3 Pin
Stian Andre Olsen4-Sep-13 1:45
Stian Andre Olsen4-Sep-13 1:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.