Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / QT

Decode and encode text files using Qt 5

3.54/5 (4 votes)
3 Sep 2013CPOL 18.4K   626  
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)