为什么不是QString :: localeAwareCompare()正常工作

一位芬兰客户告诉我,芬兰语的正确sorting(locale aware)是:az,å,ä,ö。

但是QString :: localeAwareCompare()在Windows Vista的Qt 4.4.2中将它返回为:a,ä,å,bo,ö,pz。

#include <qapplication.h> #include <qlocale.h> #include <iostream> #include <tchar.h> int main( int argc, char* argv[] ) { QLocale::setDefault ( QLocale( QLocale::Finnish ) ); QApplication app( argc, argv ); QString s1 = "a"; QString s2 = "ä"; QString s3 = "å"; QString s4 = "b"; QString s5 = "o"; QString s6 = "ö"; QString s7 = "z"; std::cout << "QString::localeAwareCompare( s1, s2 )=" << QString::localeAwareCompare( s1, s2 ) << "\n"; std::cout << "QString::localeAwareCompare( s2, s3 )=" << QString::localeAwareCompare( s2, s3 ) << "\n"; std::cout << "QString::localeAwareCompare( s3, s4 )=" << QString::localeAwareCompare( s3, s4 ) << "\n"; std::cout << "QString::localeAwareCompare( s4, s5 )=" << QString::localeAwareCompare( s4, s5 ) << "\n"; std::cout << "QString::localeAwareCompare( s5, s6 )=" << QString::localeAwareCompare( s5, s6 ) << "\n"; std::cout << "QString::localeAwareCompare( s5, s6 )=" << QString::localeAwareCompare( s6, s7 ) << "\n"; return app.exec(); } 

输出:

 QString::localeAwareCompare( s1, s2 )=-1 QString::localeAwareCompare( s2, s3 )=-1 QString::localeAwareCompare( s3, s4 )=-1 QString::localeAwareCompare( s4, s5 )=-1 QString::localeAwareCompare( s5, s6 )=-1 QString::localeAwareCompare( s5, s6 )=-1 

我的芬兰客户正在得到相同的结果。 这是一个错误还是我做错了什么?

Solutions Collecting From Web of "为什么不是QString :: localeAwareCompare()正常工作"

我在Windows XP的Qt 4.6.2中测试了你的代码,并且这些字符排序正确。 用你的测试用例,我得到以下输出:

 QString::localeAwareCompare( s1, s2 )=-1 QString::localeAwareCompare( s2, s3 )=1 QString::localeAwareCompare( s3, s4 )=1 QString::localeAwareCompare( s4, s5 )=-1 QString::localeAwareCompare( s5, s6 )=-1 QString::localeAwareCompare( s5, s6 )=1 

作为一个芬兰人,我可以确认你的客户对芬兰的排序顺序是正确的。

那么也许你可以升级到一个新的Qt版本?