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. Reading file with an unknown charset
Forum Updated to NodeBB v4.3 + New Features

Reading file with an unknown charset

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.5k 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.
  • J Offline
    J Offline
    jcga
    wrote on last edited by
    #1

    Hi,

    I a have to read text files with Qt but I don't know a priori in which charset they are code. How can I found the charset of a text file with Qt?

    Thanks,

    jclaude

    E 1 Reply Last reply
    0
    • J jcga

      Hi,

      I a have to read text files with Qt but I don't know a priori in which charset they are code. How can I found the charset of a text file with Qt?

      Thanks,

      jclaude

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @jcga Theoretically it's impossible without a priori knowledge. Practically you can make a good guess if you know at least something, e.g. that the text is some natural language. Then you can test for some characteristics, e.g. how frequently some characters or combinations are used. It's not directly related to Qt, it's a more common problem. See https://stackoverflow.com/questions/436220/determine-the-encoding-of-text-in-python.

      1 Reply Last reply
      2
      • JohanSoloJ Offline
        JohanSoloJ Offline
        JohanSolo
        wrote on last edited by
        #3

        If you're on linux, you could use file.

        `They did not know it was impossible, so they did it.'
        -- Mark Twain

        1 Reply Last reply
        1
        • jronaldJ Offline
          jronaldJ Offline
          jronald
          wrote on last edited by jronald
          #4

          libiconv can guess the charset, but it no longer supports Windows.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jcga
            wrote on last edited by
            #5

            Thank you all for your answers.

            jcga

            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