Results 1 to 6 of 6

Thread: QIODevice and QTextCodec?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QIODevice and QTextCodec?

    The encoding for the files is known, but i don't know how can i use the coding to read the file. I need to encode at this place char c = entire[i]; Ther is no problem to use QChar if that mouch more easy to handle! You understand my problem?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QIODevice and QTextCodec?

    You understand my problem?
    Not really.
    Why don't you just do exactly as shown in QTextCodec documentation?
    If you know the file encoding, then I still fail to understand your problem, unless your encoding is not supported by QTextCodec.
    From the docs:
    Qt Code:
    1. QByteArray encodedString = "..."; //from the file
    2. QTextCodec *codec = QTextCodec::codecForName("KOI8-R");
    3. QString string = codec->toUnicode(encodedString);
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2009
    Location
    Italy
    Posts
    70
    Thanks
    23
    Thanked 15 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QIODevice and QTextCodec?

    You may want to replace the QIODevice with a QTextStream and then use QTextStream::setCodec

Similar Threads

  1. Replies: 0
    Last Post: 23rd December 2009, 13:53
  2. QTextCodec bad encoding?
    By ComaWhite in forum Newbie
    Replies: 0
    Last Post: 18th September 2009, 06:15
  3. Question in QTextCodec.
    By morgana in forum Newbie
    Replies: 1
    Last Post: 21st September 2008, 16:29
  4. QTextCodec: using KOI8-R, probe failed (e0 ce ru)
    By hvengel in forum Qt Programming
    Replies: 0
    Last Post: 4th October 2007, 21:35
  5. QTextCodec::setCodecForCStrings() in libraries
    By conexion2000 in forum Qt Programming
    Replies: 5
    Last Post: 10th August 2007, 21:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.