本文整理汇总了C++中QTextCodec::aliases方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCodec::aliases方法的具体用法?C++ QTextCodec::aliases怎么用?C++ QTextCodec::aliases使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCodec
的用法示例。
在下文中一共展示了QTextCodec::aliases方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerEncodingNames
void TextCodecQt::registerEncodingNames(EncodingNameRegistrar registrar)
{
QList<int> mibs = QTextCodec::availableMibs();
// qDebug() << ">>>>>>>>> registerEncodingNames";
for (int i = 0; i < mibs.size(); ++i) {
QTextCodec *c = QTextCodec::codecForMib(mibs.at(i));
const char *name = getAtomicName(c->name());
registrar(name, name);
// qDebug() << " " << name << name;
QList<QByteArray> aliases = c->aliases();
for (int i = 0; i < aliases.size(); ++i) {
const char *a = getAtomicName(aliases.at(i));
// qDebug() << " (a) " << a << name;
registrar(a, name);
}
}
}
示例2: codecForName
QTextCodec* QTextCodec::codecForName(const char *name)
{
if (name == 0 || *name == 0)
return 0;
setup();
for (std::vector<QTextCodec*>::iterator i = all->begin(); i != all->end(); i++) {
QTextCodec *cursor = *i;
if (nameMatch(cursor->name(), name))
return cursor;
const Aliase* aliases = cursor->aliases();
for (int i = 0; aliases[i]; ++i)
if (nameMatch(aliases[i], name))
return cursor;
}
return 0;
}
示例3: createForName
/*!
Searches all installed QTextCodec objects and returns the one
which best matches \a name; the match is case-insensitive. Returns
0 if no codec matching the name \a name could be found.
*/
QTextCodec *QTextCodec::codecForName(const QByteArray &name)
{
if (name.isEmpty())
return 0;
setup();
for (int i = 0; i < all->size(); ++i) {
QTextCodec *cursor = all->at(i);
if (nameMatch(cursor->name(), name))
return cursor;
QList<QByteArray> aliases = cursor->aliases();
for (int i = 0; i < aliases.size(); ++i)
if (nameMatch(aliases.at(i), name))
return cursor;
}
return createForName(name);
}
示例4: locker
/*!
\threadsafe
Searches all installed QTextCodec objects and returns the one
which best matches \a name; the match is case-insensitive. Returns
0 if no codec matching the name \a name could be found.
*/
QTextCodec *QTextCodec::codecForName(const QByteArray &name)
{
if (name.isEmpty())
return 0;
QMutexLocker locker(textCodecsMutex());
QCoreGlobalData *globalData = QCoreGlobalData::instance();
if (!globalData)
return 0;
setup();
#ifndef QT_USE_ICU
QTextCodecCache *cache = &globalData->codecCache;
QTextCodec *codec;
if (cache) {
codec = cache->value(name);
if (codec)
return codec;
}
for (TextCodecListConstIt it = globalData->allCodecs.constBegin(), cend = globalData->allCodecs.constEnd(); it != cend; ++it) {
QTextCodec *cursor = *it;
if (qTextCodecNameMatch(cursor->name(), name)) {
if (cache)
cache->insert(name, cursor);
return cursor;
}
QList<QByteArray> aliases = cursor->aliases();
for (ByteArrayListConstIt ait = aliases.constBegin(), acend = aliases.constEnd(); ait != acend; ++ait) {
if (qTextCodecNameMatch(*ait, name)) {
if (cache)
cache->insert(name, cursor);
return cursor;
}
}
}
return 0;
#else
return QIcuCodec::codecForNameUnlocked(name);
#endif
}
示例5: locker
/*!
\threadsafe
Searches all installed QTextCodec objects and returns the one
which best matches \a name; the match is case-insensitive. Returns
0 if no codec matching the name \a name could be found.
*/
QTextCodec *QTextCodec::codecForName(const QByteArray &name)
{
if (name.isEmpty())
return 0;
QMutexLocker locker(textCodecsMutex());
QCoreGlobalData *globalData = QCoreGlobalData::instance();
if (!globalData)
return 0;
setup();
#ifndef QT_USE_ICU
QTextCodecCache *cache = &globalData->codecCache;
QTextCodec *codec;
if (cache) {
codec = cache->value(name);
if (codec)
return codec;
}
for (int i = 0; i < globalData->allCodecs.size(); ++i) {
QTextCodec *cursor = globalData->allCodecs.at(i);
if (qTextCodecNameMatch(cursor->name(), name)) {
if (cache)
cache->insert(name, cursor);
return cursor;
}
QList<QByteArray> aliases = cursor->aliases();
for (int y = 0; y < aliases.size(); ++y)
if (qTextCodecNameMatch(aliases.at(y), name)) {
if (cache)
cache->insert(name, cursor);
return cursor;
}
}
return 0;
#else
return QIcuCodec::codecForNameUnlocked(name);
#endif
}
示例6: locker
/*!
Searches all installed QTextCodec objects and returns the one
which best matches \a name; the match is case-insensitive. Returns
0 if no codec matching the name \a name could be found.
*/
QTextCodec *QTextCodec::codecForName(const QByteArray &name)
{
if (name.isEmpty())
return 0;
QMutexLocker locker(textCodecsMutex());
setup();
if (!validCodecs())
return 0;
QTextCodecCache *cache = qTextCodecCache();
QTextCodec *codec;
if (cache) {
codec = cache->value(name);
if (codec)
return codec;
}
for (int i = 0; i < all->size(); ++i) {
QTextCodec *cursor = all->at(i);
if (nameMatch(cursor->name(), name)) {
if (cache)
cache->insert(name, cursor);
return cursor;
}
QList<QByteArray> aliases = cursor->aliases();
for (int y = 0; y < aliases.size(); ++y)
if (nameMatch(aliases.at(y), name)) {
if (cache)
cache->insert(name, cursor);
return cursor;
}
}
codec = createForName(name);
if (codec && cache)
cache->insert(name, codec);
return codec;
}
示例7: if
QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name)
{
// backwards compatibility with Qt 4.x
if (!qstrcmp(name, "CP949"))
name = "windows-949";
// these are broken data in ICU 4.4, and can't be resolved even though they are aliases to tis-620
if (!qstrcmp(name, "windows-874-2000")
|| !qstrcmp(name, "windows-874")
|| !qstrcmp(name, "MS874")
|| !qstrcmp(name, "x-windows-874")
|| !qstrcmp(name, "ISO 8859-11"))
name = "TIS-620";
UErrorCode error = U_ZERO_ERROR;
// MIME gives better default names
const char *standardName = ucnv_getStandardName(name, "MIME", &error);
if (U_FAILURE(error) || !standardName) {
error = U_ZERO_ERROR;
standardName = ucnv_getStandardName(name, "IANA", &error);
}
bool qt_only = false;
if (U_FAILURE(error) || !standardName) {
standardName = name;
qt_only = true;
} else {
// correct some issues where the ICU data set contains duplicated entries.
// Where this happens it's because one data set is a subset of another. We
// always use the larger data set.
if (qstrcmp(standardName, "GB2312") == 0 || qstrcmp(standardName, "GB_2312-80") == 0)
standardName = "GBK";
else if (qstrcmp(standardName, "KSC_5601") == 0 || qstrcmp(standardName, "EUC-KR") == 0 || qstrcmp(standardName, "cp1363") == 0)
standardName = "windows-949";
}
QCoreGlobalData *globalData = QCoreGlobalData::instance();
QTextCodecCache *cache = &globalData->codecCache;
QTextCodec *codec;
if (cache) {
codec = cache->value(standardName);
if (codec)
return codec;
}
for (int i = 0; i < globalData->allCodecs.size(); ++i) {
QTextCodec *cursor = globalData->allCodecs.at(i);
if (qTextCodecNameMatch(cursor->name(), standardName)) {
if (cache)
cache->insert(standardName, cursor);
return cursor;
}
QList<QByteArray> aliases = cursor->aliases();
for (int y = 0; y < aliases.size(); ++y)
if (qTextCodecNameMatch(aliases.at(y), standardName)) {
if (cache)
cache->insert(standardName, cursor);
return cursor;
}
}
QTextCodec *c = loadQtCodec(standardName);
if (c)
return c;
if (qt_only)
return 0;
// check whether there is really a converter for the name available.
UConverter *conv = ucnv_open(standardName, &error);
if (!conv) {
qDebug() << "codecForName: ucnv_open failed" << standardName << u_errorName(error);
return 0;
}
//qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName;
ucnv_close(conv);
c = new QIcuCodec(standardName);
if (cache)
cache->insert(standardName, c);
return c;
}