PDA

View Full Version : QTextCodec decode chinese gb2312 crashing...



denny.t
29th March 2006, 08:52
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:

zlatko
29th March 2006, 10:21
Maiby another win open source bug :confused:

jpn
29th March 2006, 10:38
Maybe you should add a check for if the codec could be found.
In MainWindow::load():


QTextCodec *codec = QTextCodec::codecForName(codecName);
if (codec) {
QString str = codec->toUnicode(data);
ui.textEdit->setPlainText(str);
}



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?

denny.t
31st March 2006, 06:50
thanks~~~~~

all is ok~