Results 1 to 3 of 3

Thread: Japanese character read from html file and show in QTextEdit

  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Japanese character read from html file and show in QTextEdit

    Hi

    I am using Qt 4.8.7 on Windows. I have one Japanese HTML file, I have to read it using QTextStream's readAll() and display it into QTextEdit. But it show Garbage character and not actual Japanese character...

    QFile file(FilePath);
    file.open(QFile::ReadOnly | QFile::Text);

    QTextStream in(&file);
    QString strData = in.readAll();

    m_pTextEdit->setText(strData);

    But it show garbage character.. What am I doing wrong.

    Thanks
    Santosh

  2. #2
    Join Date
    Dec 2016
    Posts
    10
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Japanese character read from html file and show in QTextEdit

    whatever u have done is wrong ..retry once again..add certain library fucntion and get into it..

    refer this'

    doc.qt.io/qt-5/qtexamplesandtutorials.html

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Japanese character read from html file and show in QTextEdit

    Quote Originally Posted by santosh.kumar View Post
    But it show garbage character.. What am I doing wrong.
    First thing you should try is calling QTextEdit::setHtml() instead of setText() if the content is HTML.

    Second, check that your file is encoded in UTF-8 or set a different codec on the QTextStream.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 29th June 2012, 15:13
  2. Replies: 5
    Last Post: 8th September 2011, 10:38
  3. Replies: 0
    Last Post: 29th July 2010, 08:15
  4. read an xml file with Asian characters in QTextEdit
    By Boris Liao in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2010, 22:56
  5. How to read QStringList character by character
    By iamjayanth in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2009, 11:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.