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. Automatic input encoding detection for Qt?
Forum Updated to NodeBB v4.3 + New Features

Automatic input encoding detection for Qt?

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

    While working with my text editor(*), I tried to implement the same sort of automatic input encoding detection system I have in my Python version. It detects input encoding using encoding errors:

    [code]
    decodings = [ "utf-8", "latin-1" ]
    def decode(self, content):
    for codec in self.decodings:
    try:
    content = unicode(content, codec)
    except UnicodeDecodeError:
    continue
    return content
    raise Exception("Unknown encoding: " + filename)
    [/code]

    I searched Qt documentation, but I was not able to find out, how to detect encoding errors with QTextStream. Is there any way to detect the input file encoding with Qt?

    (*) Now it can be found at gitorious: https://gitorious.org/moe - it is not exactly ready for co-operative development, but I try to fix the problems.

    http://mkoskim.wordpress.com
    http://mkoskim.drivehq.com
    http://mkoskim.deviantart.com

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lygstate
      wrote on last edited by
      #2

      Ping for this, should automatically detecting UTF8 and ANSI encoding at least,

      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