コード例 #1
0
QT_BEGIN_NAMESPACE

void QCollatorPrivate::init()
{
    cleanup();
    LocaleRef localeRef;
    int rc = LocaleRefFromLocaleString(locale.bcp47Name().toLocal8Bit(), &localeRef);
    if (rc != 0)
        qWarning() << "couldn't initialize the locale";

    UInt32 options = 0;

    if (caseSensitivity == Qt::CaseInsensitive)
        options |= kUCCollateCaseInsensitiveMask;
    if (numericMode)
        options |= kUCCollateDigitsAsNumberMask | kUCCollateDigitsOverrideMask;
    if (ignorePunctuation)
        options |= kUCCollatePunctuationSignificantMask;

    OSStatus status = UCCreateCollator(
        localeRef,
        0,
        options,
        &collator
    );
    if (status != 0)
        qWarning() << "Couldn't initialize the collator";

    dirty = false;
}
コード例 #2
0
ファイル: ubrkperf.cpp プロジェクト: andrewleech/firebird
void createMACBrkIt() {
  OSStatus status = noErr;
  LocaleRef lref;
  status = LocaleRefFromLocaleString(opt_locale, &lref);
  status = UCCreateTextBreakLocator(lref, 0, kUCTextBreakAllMask, (TextBreakLocatorRef*)&breakRef);
  if(opt_char == TRUE) {
    macBreakType = kUCTextBreakClusterMask;
  } else if(opt_word == TRUE) {
    macBreakType = kUCTextBreakWordMask;
  } else if(opt_line == TRUE) {
    macBreakType = kUCTextBreakLineMask;
  } else if(opt_sentence == TRUE) {
    // error
    // brkit = BreakIterator::createSentenceInstance(opt_locale, status);
  } else {
    // default is character iterator
    macBreakType = kUCTextBreakClusterMask;
      }
}