/*! Set the codec to \a c; this will be returned by codecForLocale(). If \a c is a null pointer, the codec is reset to the default. This might be needed for some applications that want to use their own mechanism for setting the locale. \sa codecForLocale() */ void QTextCodec::setCodecForLocale(QTextCodec *c) { QMutexLocker locker(textCodecsMutex()); localeMapper = c; if (!localeMapper) setupLocaleMapper(); }
QTextCodec* QTextCodec::codecForLocale() { QCoreGlobalData *globalData = QCoreGlobalData::instance(); if (!globalData) return 0; QTextCodec *codec = globalData->codecForLocale.loadAcquire(); if (!codec) { #ifdef QT_USE_ICU textCodecsMutex()->lock(); codec = QIcuCodec::defaultCodecUnlocked(); textCodecsMutex()->unlock(); #else // setupLocaleMapper locks as necessary codec = setupLocaleMapper(); #endif } return codec; }
static void setup() { #ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(&all)); #endif if (all) return; #ifdef Q_DEBUG_TEXTCODEC if (destroying_is_ok) qWarning("QTextCodec: Creating new codec during codec cleanup"); #endif all = new QList<QTextCodec*>; // create the cleanup object to cleanup all codecs on exit (void) createQTextCodecCleanup(); #ifndef QT_NO_CODECS # if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED) // no font codecs when bootstrapping (void)new QFontLaoCodec; # if defined(QT_NO_ICONV) // no iconv(3) support, must build all codecs into the library (void)new QFontGb2312Codec; (void)new QFontGbkCodec; (void)new QFontGb18030_0Codec; (void)new QFontJis0208Codec; (void)new QFontJis0201Codec; (void)new QFontKsc5601Codec; (void)new QFontBig5hkscsCodec; (void)new QFontBig5Codec; # endif // QT_NO_ICONV && !QT_BOOTSTRAPPED # endif // Q_WS_X11 (void)new QTsciiCodec; for (int i = 0; i < 9; ++i) (void)new QIsciiCodec(i); # if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) // no asian codecs when bootstrapping, sorry (void)new QGb18030Codec; (void)new QGbkCodec; (void)new QGb2312Codec; (void)new QEucJpCodec; (void)new QJisCodec; (void)new QSjisCodec; (void)new QEucKrCodec; (void)new QCP949Codec; (void)new QBig5Codec; (void)new QBig5hkscsCodec; # endif // QT_NO_ICONV && !QT_BOOTSTRAPPED #endif // QT_NO_CODECS #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) (void) new QWindowsLocalCodec; #endif // Q_OS_WIN32 (void)new QUtf16Codec; (void)new QUtf16BECodec; (void)new QUtf16LECodec; (void)new QUtf32Codec; (void)new QUtf32BECodec; (void)new QUtf32LECodec; (void)new QLatin15Codec; (void)new QLatin1Codec; (void)new QUtf8Codec; for (int i = 0; i < QSimpleTextCodec::numSimpleCodecs; ++i) (void)new QSimpleTextCodec(i); #if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) // QIconvCodec depends on the UTF-16 codec, so it needs to be created last (void) new QIconvCodec(); #endif if (!localeMapper) setupLocaleMapper(); }
/*! Set the codec to \a c; this will be returned by codecForLocale(). If \a c is a null pointer, the codec is reset to the default. This might be needed for some applications that want to use their own mechanism for setting the locale. \sa codecForLocale() */ void QTextCodec::setCodecForLocale(QTextCodec *c) { localeMapper = c; if (!localeMapper) setupLocaleMapper(); }