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. [solved] Read/Write Non-ASCII Characters

[solved] Read/Write Non-ASCII Characters

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.7k 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.
  • H Offline
    H Offline
    Haftetavenscrap
    wrote on last edited by
    #1

    I'm having trouble reading and writing non-ASCII Characters

    My input file looks like this:
    Årning
    Framsle
    Læsten
    Tønele
    Røbtoft
    Skærbæk
    Falling
    Loskær
    etc...

    But after reading it in using "QString contents = file.readAll();" I get:
    �rning
    Framsle
    L�sten
    T�nele
    R�btoft
    Sk�rb�k
    Falling
    Losk�r

    Is there any way to get QT to recognize these characters?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should use a QTextStream where you set the correct codec to use to parse your file

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Haftetavenscrap
        wrote on last edited by
        #3

        Thanks! It works with codec ISO 8859-1

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          Now that it is working for you, please update the thread title prepending [solved] so other forums users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

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