Results 1 to 4 of 4

Thread: QTextCodec decode chinese gb2312 crashing...

  1. #1

    Unhappy QTextCodec decode chinese gb2312 crashing...

    my application is crashing when i use QTextCodec class to decode chinese GB2312 text on other computer without Qt, but run on my machine is well. why?

    help me~

    Paltform: winxp
    Qt: 4.1.1 open source

    Code below:
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QTextCodec decode chinese gb2312 crashing...

    Maiby another win open source bug
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTextCodec decode chinese gb2312 crashing...

    Maybe you should add a check for if the codec could be found.
    In MainWindow::load():
    Qt Code:
    1. QTextCodec *codec = QTextCodec::codecForName(codecName);
    2. if (codec) {
    3. QString str = codec->toUnicode(data);
    4. ui.textEdit->setPlainText(str);
    5. }
    To copy to clipboard, switch view to plain text mode 
    As docs say:
    QTextCodec::codecForName() returns 0 if no codec matching the name name could be found.
    So I'd suspect the usage of null pointer.. Probably the "other" machine does not have the codec installed?
    Last edited by jpn; 29th March 2006 at 10:48.

  4. #4

    Default Re: QTextCodec decode chinese gb2312 crashing...

    thanks~~~~~

    all is ok~

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.