// For the probably_koi8_locales we have to look. the standard says // these are 8859-5, but almost all Russian users use KOI8-R and // incorrectly set $LANG to ru_RU. We'll check tolower() to see what // it thinks ru_RU means. // If you read the history, it seems that many Russians blame ISO and // Perestroika for the confusion. // // The real bug is that some programs break if the user specifies // ru_RU.KOI8-R. static const char * const probably_koi8_rlocales[] = { "ru", "ru_SU", "ru_RU", "russian", 0 }; static QTextCodec * ru_RU_hack(const char * i) { QTextCodec * ru_RU_codec = 0; #if !defined(QT_NO_SETLOCALE) QByteArray origlocale(setlocale(LC_CTYPE, i)); #else QByteArray origlocale(i); #endif // unicode koi8r latin5 name // 0x044E 0xC0 0xEE CYRILLIC SMALL LETTER YU // 0x042E 0xE0 0xCE CYRILLIC CAPITAL LETTER YU int latin5 = tolower(0xCE); int koi8r = tolower(0xE0); if (koi8r == 0xC0 && latin5 != 0xEE) { ru_RU_codec = QTextCodec::codecForName("KOI8-R"); } else if (koi8r != 0xC0 && latin5 == 0xEE) { ru_RU_codec = QTextCodec::codecForName("ISO 8859-5"); } else { // something else again... let's assume... *throws dice* ru_RU_codec = QTextCodec::codecForName("KOI8-R"); qWarning("QTextCodec: Using KOI8-R, probe failed (%02x %02x %s)", koi8r, latin5, i); } #if !defined(QT_NO_SETLOCALE) setlocale(LC_CTYPE, origlocale); #endif return ru_RU_codec; } #endif
// probably_koi8_locales, . // , 8859-5, // KOI8-R // $LANG "ru_RU." // tolower(), // ru_RU. // , , ISO // . // // , , // ru_RU.KOI8-R. static const char * const probably_koi8_rlocales[] = { "ru", "ru_SU", "ru_RU", "russian", 0 }; static QTextCodec * ru_RU_hack(const char * i) { QTextCodec * ru_RU_codec = 0; #if !defined(QT_NO_SETLOCALE) QByteArray origlocale(setlocale(LC_CTYPE, i)); #else QByteArray origlocale(i); #endif // unicode koi8r latin5 name // 0x044E 0xC0 0xEE CYRILLIC SMALL LETTER YU // 0x042E 0xE0 0xCE CYRILLIC CAPITAL LETTER YU int latin5 = tolower(0xCE); int koi8r = tolower(0xE0); if (koi8r == 0xC0 && latin5 != 0xEE) { ru_RU_codec = QTextCodec::codecForName("KOI8-R"); } else if (koi8r != 0xC0 && latin5 == 0xEE) { ru_RU_codec = QTextCodec::codecForName("ISO 8859-5"); } else { // - ... ... * * ru_RU_codec = QTextCodec::codecForName("KOI8-R"); qWarning("QTextCodec: Using KOI8-R, probe failed (%02x %02x %s)", koi8r, latin5, i); } #if !defined(QT_NO_SETLOCALE) setlocale(LC_CTYPE, origlocale); #endif return ru_RU_codec; } #endif
Source: https://habr.com/ru/post/J235513/More articles:パラグラフ1RabbitMQ-保留中のメッセージ望遠鏡がこれ以上組み立てられることはまずありません。モスクワルートは橋の川をバイパスします一緒に楽しもう:python + flask + google app engineスパマーはビジネス会議をスケジュールします私について、1Cスクールとコース「ソフトウェア開発の管理」の6月のモジュールについてMasterUpからのSwift-Courseの最初の講義を録音する寸前のスマートフォン:新しい曲面ディスプレイを備えたSamsung Galaxy Edge生存曲線を使用したビジネスプロセスの最適化All Articles