Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I convert text file to UTF-8 encoding ?
Forum Updated to NodeBB v4.3 + New Features

How can I convert text file to UTF-8 encoding ?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aabc
    wrote on 10 Mar 2014, 12:09 last edited by
    #1

    In Notepad++ you can choose from menu: Encoding -> Convert to UTF-8.
    How can I do it with Qt ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 10 Mar 2014, 12:40 last edited by
      #2

      Read the file, then open a new one and write the data using QTextStream set to UTF-8.

      You can do this by getting the example from "QFile":http://qt-project.org/doc/qt-5/QFile.html documentation, and combining it with "QTextStream":http://qt-project.org/doc/qt-5/qtextstream.html#setCodec-2.

      Once the new file is ready, close it, delete the original and move the new one to the old position.

      (Z(:^

      1 Reply Last reply
      0

      1/2

      10 Mar 2014, 12:09

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved