//
// codec.cpp
#include <QApplication>
#include <QLabel>
#include <QFile>
#include <QTextStream>
#pragma comment(lib,"QtCore4.lib")
#pragma comment(lib,"QtGui4.lib")
int main(int argc,char *argv[])
{
QFile infile("in.txt");
if (!infile.open(QIODevice::ReadOnly | QIODevice::Text))
return 0;
QFile outfile("out.txt");
if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text))
return 0;
QTextStream instream(&infile);
QTextStream outstream(&outfile);
instream.setCodec("UTF-8");
outstream.setCodec("GB18030");
outstream << instream.readAll();
}
//
//#include <QApplication>
//#include <QLabel>
//
//#pragma comment(lib,"QtCore4.lib")
//#pragma comment(lib,"QtGui4.lib")
//
//int main(int argc,char *argv[])
//{
// QApplication app(argc,argv);
// QLabel *label = new QLabel("hello,qt!");
// label->show();
// app.exec();
//}
/
// unicode
//#include <qapplication.h>
//#include <qlabel.h>
//
//#pragma comment(lib,"QtCore4.lib")
//#pragma comment(lib,"QtGui4.lib")
//
//int main( int argc, char *argv[] )
//{
// QApplication application( argc, argv );
// QChar unicode[] = { 0x60a8, 0x4e0a, 0x6b21, 0x8bbf, 0x95ee,
// 0x672c, 0x7ad9 };
//
// QString s( unicode, 8 );
// QLabel label( s, 0 );
// label.show();
// return application.exec();
//}
//int qDebugOutput()
//{
// QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB18030"));
//
// QDir d("N://CPP32//qt32//QFile//中文测试目录");
// d.setFilter(QDir::Files);
//
// int n = d.count();
//
// for (int i=0; i<=d.count() -1;i++)
// {
// QString s = d[i];
// qDebug() << s;
// }
//
// return n;
//}