您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ures_getStringByKey函数代码示例

51自学网 2021-06-03 09:17:13
  C++
这篇教程C++ ures_getStringByKey函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ures_getStringByKey函数的典型用法代码示例。如果您正苦于以下问题:C++ ures_getStringByKey函数的具体用法?C++ ures_getStringByKey怎么用?C++ ures_getStringByKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ures_getStringByKey函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TestFallback

static void TestFallback(){    UErrorCode status = U_ZERO_ERROR;    UResourceBundle *fr_FR = NULL;    UResourceBundle *subResource = NULL;    const UChar *junk; /* ignored */    int32_t resultLen;    log_verbose("Opening fr_FR..");    fr_FR = ures_open(NULL, "fr_FR", &status);    if(U_FAILURE(status))    {        log_err_status(status, "Couldn't open fr_FR - %s/n", u_errorName(status));        return;    }    status = U_ZERO_ERROR;    /* clear it out..  just do some calls to get the gears turning */    junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);    (void)junk;    /* Suppress set but not used warning. */    status = U_ZERO_ERROR;    junk = ures_getStringByKey(fr_FR, "LocaleString", &resultLen, &status);    status = U_ZERO_ERROR;    junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);    status = U_ZERO_ERROR;    /* OK first one. This should be a Default value. */    subResource = ures_getByKey(fr_FR, "layout", NULL, &status);    if(status != U_USING_DEFAULT_WARNING)    {        log_data_err("Expected U_USING_DEFAULT_ERROR when trying to get layout from fr_FR, got %s/n",            u_errorName(status));    }    ures_close(subResource);    status = U_ZERO_ERROR;    /* and this is a Fallback, to fr */    junk = ures_getStringByKey(fr_FR, "ExemplarCharacters", &resultLen, &status);    if(status != U_USING_FALLBACK_WARNING)    {        log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get ExemplarCharacters from fr_FR, got %s/n",             u_errorName(status));    }    status = U_ZERO_ERROR;    ures_close(fr_FR);}
开发者ID:icu-project,项目名称:icu4c,代码行数:50,


示例2: ulocdata_getExemplarSet

U_CAPI USet* U_EXPORT2ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,                        uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status){    static const char* const exemplarSetTypes[] = { "ExemplarCharacters", "AuxExemplarCharacters" };    const UChar *exemplarChars = NULL;    int32_t len = 0;    UErrorCode localStatus = U_ZERO_ERROR;    if (U_FAILURE(*status))        return NULL;    exemplarChars = ures_getStringByKey(uld->bundle, exemplarSetTypes[extype], &len, &localStatus);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status))        return NULL;    if(fillIn != NULL)        uset_applyPattern(fillIn, exemplarChars, len,                          USET_IGNORE_SPACE | options, status);    else        fillIn = uset_openPatternOptions(exemplarChars, len,                                         USET_IGNORE_SPACE | options, status);    return fillIn;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:34,


示例3: ucurr_forLocale

U_CAPI const UChar* U_EXPORT2ucurr_forLocale(const char* locale, UErrorCode* ec) {    if (ec != NULL && U_SUCCESS(*ec)) {        char id[ULOC_FULLNAME_CAPACITY];        idForLocale(locale, id, sizeof(id), ec);        if (U_FAILURE(*ec)) {            return NULL;        }                const UChar* result = CReg::get(id);        if (result) {            return result;        }                // Look up the CurrencyMap element in the root bundle.        UResourceBundle* rb = ures_open(NULL, "", ec);        UResourceBundle* cm = ures_getByKey(rb, CURRENCY_MAP, NULL, ec);        int32_t len;        const UChar* s = ures_getStringByKey(cm, id, &len, ec);        ures_close(cm);        ures_close(rb);                if (U_SUCCESS(*ec)) {            return s;        }    }    return NULL;}
开发者ID:gitpan,项目名称:ponie,代码行数:28,


示例4: u_strlen

const UChar*ZoneMeta::getShortIDFromCanonical(const UChar* canonicalID) {    const UChar* shortID = NULL;    int32_t len = u_strlen(canonicalID);    char tzidKey[ZID_KEY_MAX + 1];    u_UCharsToChars(canonicalID, tzidKey, len);    tzidKey[len] = (char) 0; // Make sure it is null terminated.    // replace '/' with ':'    char *p = tzidKey;    while (*p++) {        if (*p == '/') {            *p = ':';        }    }    UErrorCode status = U_ZERO_ERROR;    UResourceBundle *rb = ures_openDirect(NULL, gKeyTypeData, &status);    ures_getByKey(rb, gTypeMapTag, rb, &status);    ures_getByKey(rb, gTimezoneTag, rb, &status);    shortID = ures_getStringByKey(rb, tzidKey, NULL, &status);    ures_close(rb);    return shortID;}
开发者ID:basti1302,项目名称:node,代码行数:26,


示例5: ucol_getRulesEx

U_CAPI int32_t U_EXPORT2ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen) {    UErrorCode status = U_ZERO_ERROR;    int32_t len = 0;    int32_t UCAlen = 0;    const UChar* ucaRules = 0;    const UChar *rules = ucol_getRules(coll, &len);    if(delta == UCOL_FULL_RULES) {        /* take the UCA rules and append real rules at the end */        /* UCA rules will be probably coming from the root RB */        ucaRules = ures_getStringByKey(coll->rb,"UCARules",&UCAlen,&status);        /*        UResourceBundle* cresb = ures_getByKeyWithFallback(coll->rb, "collations", NULL, &status);        UResourceBundle*  uca = ures_getByKeyWithFallback(cresb, "UCA", NULL, &status);        ucaRules = ures_getStringByKey(uca,"Sequence",&UCAlen,&status);        ures_close(uca);        ures_close(cresb);        */    }    if(U_FAILURE(status)) {        return 0;    }    if(buffer!=0 && bufferLen>0){        *buffer=0;        if(UCAlen > 0) {            u_memcpy(buffer, ucaRules, uprv_min(UCAlen, bufferLen));        }        if(len > 0 && bufferLen > UCAlen) {            u_memcpy(buffer+UCAlen, rules, uprv_min(len, bufferLen-UCAlen));        }    }    return u_terminateUChars(buffer, bufferLen, len+UCAlen, &status);}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:33,


示例6: create

  virtual UObject* create(const ICUServiceKey& key, const ICUService* /*service*/, UErrorCode& status) const  {  LocaleKey &lkey = (LocaleKey&)key;  Locale loc;  lkey.currentLocale(loc);#ifdef U_DEBUG_CALSVC  fprintf(stderr, "DefaultCalendar factory %p: looking up %s/n",           this, (const char*)loc.getName());#endif  UErrorCode resStatus = U_ZERO_ERROR;  UResourceBundle *rb = ures_open(NULL, (const char*)loc.getName(), &resStatus);#ifdef U_DEBUG_CALSVC  fprintf(stderr, "... ures_open -> %s/n", u_errorName(resStatus));#endif  if(U_FAILURE(resStatus) ||      (resStatus == U_USING_DEFAULT_WARNING) || (resStatus==U_USING_FALLBACK_WARNING)) { //Don't want to handle fallback data.    ures_close(rb);    status = resStatus; // propagate err back to caller#ifdef U_DEBUG_CALSVC    fprintf(stderr, "... exitting (NULL)/n");#endif    return NULL;  }  int32_t len = 0;  UnicodeString myString = ures_getUnicodeStringByKey(rb, Calendar::kDefaultCalendar, &status);#ifdef U_DEBUG_CALSVC  UErrorCode debugStatus = U_ZERO_ERROR;  const UChar *defCal = ures_getStringByKey(rb, Calendar::kDefaultCalendar, &len,  &debugStatus);  fprintf(stderr, "... get string(%d) -> %s/n", len, u_errorName(debugStatus));#endif  ures_close(rb);     if(U_FAILURE(status)) {    return NULL;  } #ifdef U_DEBUG_CALSVC   {     char defCalStr[200];     if(len > 199) {       len = 199;     }     u_UCharsToChars(defCal, defCalStr, len);     defCalStr[len]=0;     fprintf(stderr, "DefaultCalendarFactory: looked up %s, got DefaultCalendar= %s/n",  (const char*)loc.getName(), defCalStr);   }#endif   return myString.clone(); }
开发者ID:gitpan,项目名称:ponie,代码行数:60,


示例7: usage

static void usage(const char *pname, int ecode) {    const UChar *msg;    int32_t msgLen;    UErrorCode err = U_ZERO_ERROR;    FILE *fp = ecode ? stderr : stdout;    int res;    initMsg(pname);    msg =        ures_getStringByKey(gBundle, ecode ? "lcUsageWord" : "ucUsageWord",                            &msgLen, &err);    UnicodeString upname(pname, (int32_t)(uprv_strlen(pname) + 1));    UnicodeString mname(msg, msgLen + 1);    res = u_wmsg(fp, "usage", mname.getBuffer(), upname.getBuffer());    if (!ecode) {        if (!res) {            fputc('/n', fp);        }        if (!u_wmsg(fp, "help")) {            /* Now dump callbacks and finish. */            int i, count =                sizeof(transcode_callbacks) / sizeof(*transcode_callbacks);            for (i = 0; i < count; ++i) {                fprintf(fp, " %s", transcode_callbacks[i].name);            }            fputc('/n', fp);        }    }    exit(ecode);}
开发者ID:gitpan,项目名称:ponie,代码行数:33,


示例8: UMTX_CHECK

const char*TimeZone::getTZDataVersion(UErrorCode& status){    /* This is here to prevent race conditions. */    UBool needsInit;    UMTX_CHECK(&LOCK, !TZDataVersionInitialized, needsInit);    if (needsInit) {        int32_t len = 0;        UResourceBundle *bundle = ures_openDirect(NULL, "zoneinfo", &status);        const UChar *tzver = ures_getStringByKey(bundle, "TZVersion",            &len, &status);        if (U_SUCCESS(status)) {            if (len >= (int32_t)sizeof(TZDATA_VERSION)) {                // Ensure that there is always space for a trailing nul in TZDATA_VERSION                len = sizeof(TZDATA_VERSION) - 1;            }            umtx_lock(&LOCK);            if (!TZDataVersionInitialized) {                u_UCharsToChars(tzver, TZDATA_VERSION, len);                TZDataVersionInitialized = TRUE;            }            umtx_unlock(&LOCK);            ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);        }        ures_close(bundle);    }    if (U_FAILURE(status)) {        return NULL;    }    return (const char*)TZDATA_VERSION;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:33,


示例9: uloc_countAvailable

voidResourceBundleTest::TestExemplar(){    int32_t locCount = uloc_countAvailable();    int32_t locIndex=0;    int num=0;    UErrorCode status = U_ZERO_ERROR;    for(;locIndex<locCount;locIndex++){        const char* locale = uloc_getAvailable(locIndex);        UResourceBundle *resb =ures_open(NULL,locale,&status);        if(U_SUCCESS(status) && status!=U_USING_FALLBACK_WARNING && status!=U_USING_DEFAULT_WARNING){            int32_t len=0;            const UChar* strSet = ures_getStringByKey(resb,"ExemplarCharacters",&len,&status);            UnicodeSet set(strSet,status);            if(U_FAILURE(status)){                errln("Could not construct UnicodeSet from pattern for ExemplarCharacters in locale : %s. Error: %s",locale,u_errorName(status));                status=U_ZERO_ERROR;            }            num++;        }        ures_close(resb);    }    logln("Number of installed locales with exemplar characters that could be tested: %d",num);}
开发者ID:Acorld,项目名称:WinObjC-Heading,代码行数:25,


示例10: u_catgets

U_CAPI const UChar* U_EXPORT2u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,          const UChar* s,          int32_t* len, UErrorCode* ec) {    char key[MAX_KEY_LEN];    const UChar* result;    if (ec == NULL || U_FAILURE(*ec)) {        goto ERROR;    }    result = ures_getStringByKey((const UResourceBundle*) catd,                                 _catkey(key, set_num, msg_num),                                 len, ec);    if (U_FAILURE(*ec)) {        goto ERROR;    }    return result; ERROR:    /* In case of any failure, return s */    if (len != NULL) {        *len = u_strlen(s);    }    return s;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:28,


示例11: ures_openDirect

UnicodeString& U_EXPORT2ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &region, UnicodeString &result) {    UErrorCode status = U_ZERO_ERROR;    const UChar *tzid = NULL;    int32_t tzidLen = 0;    char keyBuf[ZID_KEY_MAX + 1];    int32_t keyLen = 0;    if (mzid.isBogus() || mzid.length() > ZID_KEY_MAX) {        result.setToBogus();        return result;    }    keyLen = mzid.extract(0, mzid.length(), keyBuf, ZID_KEY_MAX + 1, US_INV);    keyBuf[keyLen] = 0;    UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);    ures_getByKey(rb, gMapTimezonesTag, rb, &status);    ures_getByKey(rb, keyBuf, rb, &status);    if (U_SUCCESS(status)) {        // check region mapping        if (region.length() == 2 || region.length() == 3) {            keyLen = region.extract(0, region.length(), keyBuf, ZID_KEY_MAX + 1, US_INV);            keyBuf[keyLen] = 0;            tzid = ures_getStringByKey(rb, keyBuf, &tzidLen, &status);            if (status == U_MISSING_RESOURCE_ERROR) {                status = U_ZERO_ERROR;            }        }        if (U_SUCCESS(status) && tzid == NULL) {            // try "001"            tzid = ures_getStringByKey(rb, gWorldTag, &tzidLen, &status);        }    }    ures_close(rb);    if (tzid == NULL) {        result.setToBogus();    } else {        result.setTo(tzid, tzidLen);    }    return result;}
开发者ID:basti1302,项目名称:node,代码行数:45,


示例12: setStringField

static void setStringField(JNIEnv* env, jobject obj, const char* fieldName, UResourceBundle* bundle, const char* key) {  UErrorCode status = U_ZERO_ERROR;  int charCount;  const UChar* chars = ures_getStringByKey(bundle, key, &charCount, &status);  if (U_SUCCESS(status)) {    setStringField(env, obj, fieldName, env->NewString(chars, charCount));  } else {    ALOGE("Error setting String field %s from ICU resource (key %s): %s", fieldName, key, u_errorName(status));  }}
开发者ID:AlexeyBychkov,项目名称:robovm,代码行数:10,


示例13: ures_getStringByKey

UBool LocaleAliasTest::isLocaleAvailable(const char* loc){    if(resIndex==NULL){        return FALSE;    }    UErrorCode status = U_ZERO_ERROR;    int32_t len = 0;    ures_getStringByKey(resIndex, loc,&len, &status);    if(U_FAILURE(status)){        return FALSE;     }    return TRUE;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:12,


示例14: ulocdata_getDelimiter

U_CAPI int32_t U_EXPORT2ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,                      UChar *result, int32_t resultLength, UErrorCode *status){    static const char* const delimiterKeys[] =  {        "quotationStart",        "quotationEnd",        "alternateQuotationStart",        "alternateQuotationEnd"    };    UResourceBundle *delimiterBundle;    int32_t len = 0;    const UChar *delimiter = NULL;    UErrorCode localStatus = U_ZERO_ERROR;    if (U_FAILURE(*status))        return 0;    delimiterBundle = ures_getByKey(uld->bundle, "delimiters", NULL, &localStatus);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        ures_close(delimiterBundle);        return 0;    }    delimiter = ures_getStringByKey(delimiterBundle, delimiterKeys[type], &len, &localStatus);    ures_close(delimiterBundle);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        return 0;    }    u_strncpy(result,delimiter, resultLength);    return len;}
开发者ID:JoeDoyle23,项目名称:node,代码行数:52,


示例15: tryOpeningFromRules

U_CDECL_END/****************************************************************************//* Following are the open/close functions                                   *//*                                                                          *//****************************************************************************/static UCollator*tryOpeningFromRules(UResourceBundle *collElem, UErrorCode *status) {    int32_t rulesLen = 0;    const UChar *rules = ures_getStringByKey(collElem, "Sequence", &rulesLen, status);    return ucol_openRules(rules, rulesLen, UCOL_DEFAULT, UCOL_DEFAULT, NULL, status);}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:13,


示例16: _getStringOrCopyKey

static int32_t_getStringOrCopyKey(const char *path, const char *locale,                    const char *tableKey,                     const char* subTableKey,                    const char *itemKey,                    const char *substitute,                    UChar *dest, int32_t destCapacity,                    UErrorCode *pErrorCode) {    const UChar *s = NULL;    int32_t length = 0;    if(itemKey==NULL) {        /* top-level item: normal resource bundle access */        UResourceBundle *rb;        rb=ures_open(path, locale, pErrorCode);        if(U_SUCCESS(*pErrorCode)) {            s=ures_getStringByKey(rb, tableKey, &length, pErrorCode);            /* see comment about closing rb near "return item;" in _res_getTableStringWithFallback() */            ures_close(rb);        }    } else {        /* Language code should not be a number. If it is, set the error code. */        if (!uprv_strncmp(tableKey, "Languages", 9) && uprv_strtol(itemKey, NULL, 10)) {            *pErrorCode = U_MISSING_RESOURCE_ERROR;        } else {            /* second-level item, use special fallback */            s=uloc_getTableStringWithFallback(path, locale,                                               tableKey,                                                subTableKey,                                               itemKey,                                               &length,                                               pErrorCode);        }    }    if(U_SUCCESS(*pErrorCode)) {        int32_t copyLength=uprv_min(length, destCapacity);        if(copyLength>0 && s != NULL) {            u_memcpy(dest, s, copyLength);        }    } else {        /* no string from a resource bundle: convert the substitute */        length=(int32_t)uprv_strlen(substitute);        u_charsToUChars(substitute, dest, uprv_min(length, destCapacity));        *pErrorCode=U_USING_DEFAULT_WARNING;    }    return u_terminateUChars(dest, destCapacity, length, pErrorCode);}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:51,


示例17: u_errorName

U_CFUNC const UChar *u_wmsg_errorName(UErrorCode err){    UChar *msg;    int32_t msgLen;    UErrorCode subErr = U_ZERO_ERROR;    const char *textMsg = NULL;    /* try the cache */    msg = (UChar*)fetchErrorName(err);    if(msg)    {        return msg;    }    if(gBundle == NULL)    {        msg = NULL;    }    else    {        const char *errname = u_errorName(err);        if (errname) {            msg = (UChar*)ures_getStringByKey(gBundle, errname, &msgLen, &subErr);            if(U_FAILURE(subErr))            {                msg = NULL;            }        }    }    if(msg == NULL)  /* Couldn't find it anywhere.. */    {        char error[128];        textMsg = u_errorName(err);        if (!textMsg) {            sprintf(error, "UNDOCUMENTED ICU ERROR %d", err);            textMsg = error;        }        msg = (UChar*)malloc((strlen(textMsg)+1)*sizeof(msg[0]));        u_charsToUChars(textMsg, msg, (int32_t)(strlen(textMsg)+1));    }    if(err>=0)        gErrMessages[err] = msg;    else        gInfoMessages[err-U_ERROR_WARNING_START] = msg;    return msg;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:50,


示例18: ulocdata_getLocaleSeparator

U_DRAFT int32_t U_EXPORT2ulocdata_getLocaleSeparator(ULocaleData *uld,                            UChar *result,                            int32_t resultCapacity,                            UErrorCode *status)  {    UResourceBundle *separatorBundle;    int32_t len = 0;    const UChar *separator = NULL;    UErrorCode localStatus = U_ZERO_ERROR;    if (U_FAILURE(*status))        return 0;    separatorBundle = ures_getByKey(uld->bundle, "localeDisplayPattern", NULL, &localStatus);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        ures_close(separatorBundle);        return 0;    }    separator = ures_getStringByKey(separatorBundle, "separator", &len, &localStatus);    ures_close(separatorBundle);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        return 0;    }    u_strncpy(result, separator, resultCapacity);    return len;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:47,


示例19: ucnv_getDisplayName

U_CAPI int32_t U_EXPORT2ucnv_getDisplayName(const UConverter *cnv,                    const char *displayLocale,                    UChar *displayName, int32_t displayNameCapacity,                    UErrorCode *pErrorCode) {    UResourceBundle *rb;    const UChar *name;    int32_t length;    UErrorCode localStatus = U_ZERO_ERROR;    /* check arguments */    if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {        return 0;    }    if(cnv==NULL || displayNameCapacity<0 || (displayNameCapacity>0 && displayName==NULL)) {        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;        return 0;    }    /* open the resource bundle and get the display name string */    rb=ures_open(NULL, displayLocale, pErrorCode);    if(U_FAILURE(*pErrorCode)) {        return 0;    }    /* use the internal name as the key */    name=ures_getStringByKey(rb, cnv->sharedData->staticData->name, &length, &localStatus);    ures_close(rb);    if(U_SUCCESS(localStatus)) {        /* copy the string */        if (*pErrorCode == U_ZERO_ERROR) {            *pErrorCode = localStatus;        }        u_memcpy(displayName, name, uprv_min(length, displayNameCapacity)*U_SIZEOF_UCHAR);    } else {        /* convert the internal name into a Unicode string */        length=(int32_t)uprv_strlen(cnv->sharedData->staticData->name);        u_charsToUChars(cnv->sharedData->staticData->name, displayName, uprv_min(length, displayNameCapacity));    }    return u_terminateUChars(displayName, displayNameCapacity, length, pErrorCode);}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:43,


示例20: TestAliasConflict

void TestAliasConflict(void) {    UErrorCode status = U_ZERO_ERROR;    UResourceBundle *he = NULL;    UResourceBundle *iw = NULL;    const UChar *result = NULL;    int32_t resultLen;    he = ures_open(NULL, "he", &status);    iw = ures_open(NULL, "iw", &status);    if(U_FAILURE(status)) {        log_err_status(status, "Failed to get resource with %s/n", myErrorName(status));    }    ures_close(iw);    result = ures_getStringByKey(he, "ExemplarCharacters", &resultLen, &status);    if(U_FAILURE(status) || result == NULL) {        log_err_status(status, "Failed to get resource with %s/n", myErrorName(status));    }    ures_close(he);}
开发者ID:icu-project,项目名称:icu4c,代码行数:19,


示例21: findLikelySubtags

/** * This function looks for the localeID in the likelySubtags resource. * * @param localeID The tag to find. * @param buffer A buffer to hold the matching entry * @param bufferLength The length of the output buffer * @return A pointer to "buffer" if found, or a null pointer if not. */static const char*  U_CALLCONVfindLikelySubtags(const char* localeID,                  char* buffer,                  int32_t bufferLength,                  UErrorCode* err) {    const char* result = NULL;    if (!U_FAILURE(*err)) {        int32_t resLen = 0;        const UChar* s = NULL;        UErrorCode tmpErr = U_ZERO_ERROR;        UResourceBundle* subtags = ures_openDirect(NULL, "likelySubtags", &tmpErr);        if (U_SUCCESS(tmpErr)) {            s = ures_getStringByKey(subtags, localeID, &resLen, &tmpErr);            if (U_FAILURE(tmpErr)) {                /*                 * If a resource is missing, it's not really an error, it's                 * just that we don't have any data for that particular locale ID.                 */                if (tmpErr != U_MISSING_RESOURCE_ERROR) {                    *err = tmpErr;                }            }            else if (resLen >= bufferLength) {                /* The buffer should never overflow. */                *err = U_INTERNAL_PROGRAM_ERROR;            }            else {                u_UCharsToChars(s, buffer, resLen + 1);                result = buffer;            }            ures_close(subtags);        } else {            *err = tmpErr;        }    }    return result;}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:49,


示例22: ures_openDirect

NumberingSystem* U_EXPORT2NumberingSystem::createInstanceByName(const char *name, UErrorCode& status) {         UResourceBundle *numberingSystemsInfo = NULL;     UResourceBundle *nsTop, *nsCurrent;     const UChar* description = NULL;     int32_t radix = 10;     int32_t algorithmic = 0;     int32_t len;     numberingSystemsInfo = ures_openDirect(NULL,gNumberingSystems, &status);     nsCurrent = ures_getByKey(numberingSystemsInfo,gNumberingSystems,NULL,&status);     nsTop = ures_getByKey(nsCurrent,name,NULL,&status);     description = ures_getStringByKey(nsTop,gDesc,&len,&status);	 ures_getByKey(nsTop,gRadix,nsCurrent,&status);     radix = ures_getInt(nsCurrent,&status);     ures_getByKey(nsTop,gAlgorithmic,nsCurrent,&status);     algorithmic = ures_getInt(nsCurrent,&status);     UBool isAlgorithmic = ( algorithmic == 1 );     UnicodeString nsd;     nsd.setTo(description);	 ures_close(nsCurrent);	 ures_close(nsTop);     ures_close(numberingSystemsInfo);     if (U_FAILURE(status)) {         status = U_UNSUPPORTED_ERROR;         return NULL;     }     NumberingSystem* ns = NumberingSystem::createInstance(radix,isAlgorithmic,nsd,status);     ns->setName(name);     return ns;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:38,


示例23: unassigned

//constructorNamePrepTransform::NamePrepTransform(UParseError& parseError, UErrorCode& status): unassigned(), prohibited(), labelSeparatorSet(){            mapping = NULL;    bundle = NULL;    const char* testDataName = IntlTest::loadTestData(status);        if(U_FAILURE(status)){        return;    }        bundle = ures_openDirect(testDataName,"idna_rules",&status);        if(bundle != NULL && U_SUCCESS(status)){        // create the mapping transliterator        int32_t ruleLen = 0;        const UChar* ruleUChar = ures_getStringByKey(bundle, "MapNFKC",&ruleLen, &status);        int32_t mapRuleLen = 0;        const UChar *mapRuleUChar = ures_getStringByKey(bundle, "MapNoNormalization", &mapRuleLen, &status);        UnicodeString rule(mapRuleUChar, mapRuleLen);        rule.append(ruleUChar, ruleLen);        mapping = Transliterator::createFromRules(UnicodeString("NamePrepTransform", ""), rule,                                                   UTRANS_FORWARD, parseError,status);        if(U_FAILURE(status)) {          return;        }        //create the unassigned set        int32_t patternLen =0;        const UChar* pattern = ures_getStringByKey(bundle,"UnassignedSet",&patternLen, &status);        unassigned.applyPattern(UnicodeString(pattern, patternLen), status);        //create prohibited set        patternLen=0;        pattern =  ures_getStringByKey(bundle,"ProhibitedSet",&patternLen, &status);        UnicodeString test(pattern,patternLen);        prohibited.applyPattern(test,status);#ifdef DEBUG        if(U_FAILURE(status)){            printf("Construction of Unicode set failed/n");        }        if(U_SUCCESS(status)){            if(prohibited.contains((UChar) 0x644)){                printf("The string contains 0x644 ... damn !!/n");            }            UnicodeString temp;            prohibited.toPattern(temp,TRUE);            for(int32_t i=0;i<temp.length();i++){                printf("%c", (char)temp.charAt(i));            }            printf("/n");        }#endif                //create label separator set        patternLen=0;        pattern =  ures_getStringByKey(bundle,"LabelSeparatorSet",&patternLen, &status);        labelSeparatorSet.applyPattern(UnicodeString(pattern,patternLen),status);    }    if(U_SUCCESS(status) &&         (mapping == NULL)      ){        status = U_MEMORY_ALLOCATION_ERROR;        delete mapping;        ures_close(bundle);        mapping = NULL;        bundle = NULL;    }        }
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:77,


示例24: uprv_detectWindowsTimeZone

/** * Main Windows time zone detection function.  Returns the Windows * time zone, translated to an ICU time zone, or NULL upon failure. */U_CFUNC const char* U_EXPORT2uprv_detectWindowsTimeZone() {    UErrorCode status = U_ZERO_ERROR;    UResourceBundle* bundle = NULL;    char* icuid = NULL;    char apiStdName[MAX_LENGTH_ID];    char regStdName[MAX_LENGTH_ID];    char tmpid[MAX_LENGTH_ID];    int32_t len;    int id;    int errorCode;    UChar ISOcodeW[3]; /* 2 letter iso code in UTF-16*/    char  ISOcodeA[3]; /* 2 letter iso code in ansi */    LONG result;    TZI tziKey;    TZI tziReg;    TIME_ZONE_INFORMATION apiTZI;    BOOL isVistaOrHigher;    BOOL tryPreVistaFallback;    OSVERSIONINFO osVerInfo;    /* Obtain TIME_ZONE_INFORMATION from the API, and then convert it       to TZI.  We could also interrogate the registry directly; we do       this below if needed. */    uprv_memset(&apiTZI, 0, sizeof(apiTZI));    uprv_memset(&tziKey, 0, sizeof(tziKey));    uprv_memset(&tziReg, 0, sizeof(tziReg));    GetTimeZoneInformation(&apiTZI);    tziKey.bias = apiTZI.Bias;    uprv_memcpy((char *)&tziKey.standardDate, (char*)&apiTZI.StandardDate,           sizeof(apiTZI.StandardDate));    uprv_memcpy((char *)&tziKey.daylightDate, (char*)&apiTZI.DaylightDate,           sizeof(apiTZI.DaylightDate));    /* Convert the wchar_t* standard name to char* */    uprv_memset(apiStdName, 0, sizeof(apiStdName));    wcstombs(apiStdName, apiTZI.StandardName, MAX_LENGTH_ID);    tmpid[0] = 0;    id = GetUserGeoID(GEOCLASS_NATION);    errorCode = GetGeoInfoW(id,GEO_ISO2,ISOcodeW,3,0);    u_strToUTF8(ISOcodeA, 3, NULL, ISOcodeW, 3, &status);    bundle = ures_openDirect(NULL, "windowsZones", &status);    ures_getByKey(bundle, "mapTimezones", bundle, &status);    /*        Windows Vista+ provides us with a "TimeZoneKeyName" that is not localized        and can be used to directly map a name in our bundle. Try to use that first        if we're on Vista or higher    */    uprv_memset(&osVerInfo, 0, sizeof(osVerInfo));    osVerInfo.dwOSVersionInfoSize = sizeof(osVerInfo);    GetVersionEx(&osVerInfo);    isVistaOrHigher = osVerInfo.dwMajorVersion >= 6;	/* actually includes Windows Server 2008 as well, but don't worry about it */    tryPreVistaFallback = TRUE;    if(isVistaOrHigher) {        result = getTZKeyName(regStdName, sizeof(regStdName));        if(ERROR_SUCCESS == result) {            UResourceBundle* winTZ = ures_getByKey(bundle, regStdName, NULL, &status);            if(U_SUCCESS(status)) {                const UChar* icuTZ = NULL;                if (errorCode != 0) {                    icuTZ = ures_getStringByKey(winTZ, ISOcodeA, &len, &status);                }                if (errorCode==0 || icuTZ==NULL) {                    /* fallback to default "001" and reset status */                    status = U_ZERO_ERROR;                    icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);                }                if(U_SUCCESS(status)) {                    int index=0;                    while (! (*icuTZ == '/0' || *icuTZ ==' ')) {                        tmpid[index++]=(char)(*icuTZ++);  /* safe to assume 'char' is ASCII compatible on windows */                    }                    tmpid[index]='/0';                    tryPreVistaFallback = FALSE;                }            }            ures_close(winTZ);        }    }    if(tryPreVistaFallback) {        /* Note: We get the winid not from static tables but from resource bundle. */        while (U_SUCCESS(status) && ures_hasNext(bundle)) {            UBool idFound = FALSE;            const char* winid;            UResourceBundle* winTZ = ures_getNextResource(bundle, NULL, &status);            if (U_FAILURE(status)) {                break;//.........这里部分代码省略.........
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:101,


示例25: uprv_detectWindowsTimeZone

U_CFUNC const char* U_EXPORT2uprv_detectWindowsTimeZone() {    UErrorCode status = U_ZERO_ERROR;    UResourceBundle* bundle = NULL;    char* icuid = NULL;    LONG result;    TZI tziKey;    TZI tziReg;    TIME_ZONE_INFORMATION apiTZI;    /* Obtain TIME_ZONE_INFORMATION from the API, and then convert it       to TZI.  We could also interrogate the registry directly; we do       this below if needed. */    uprv_memset(&apiTZI, 0, sizeof(apiTZI));    uprv_memset(&tziKey, 0, sizeof(tziKey));    uprv_memset(&tziReg, 0, sizeof(tziReg));    GetTimeZoneInformation(&apiTZI);    tziKey.bias = apiTZI.Bias;    uprv_memcpy((char *)&tziKey.standardDate, (char*)&apiTZI.StandardDate,           sizeof(apiTZI.StandardDate));    uprv_memcpy((char *)&tziKey.daylightDate, (char*)&apiTZI.DaylightDate,           sizeof(apiTZI.DaylightDate));    bundle = ures_openDirect(NULL, "windowsZones", &status);    ures_getByKey(bundle, "mapTimezones", bundle, &status);    /* Note: We get the winid not from static tables but from resource bundle. */    while (U_SUCCESS(status) && ures_hasNext(bundle)) {        const char* winid;        int32_t len;        UResourceBundle* winTZ = ures_getNextResource(bundle, NULL, &status);        if (U_FAILURE(status)) {            break;        }        winid = ures_getKey(winTZ);        result = getTZI(winid, &tziReg);        if (result == ERROR_SUCCESS) {            /* Windows alters the DaylightBias in some situations.               Using the bias and the rules suffices, so overwrite               these unreliable fields. */            tziKey.standardBias = tziReg.standardBias;            tziKey.daylightBias = tziReg.daylightBias;            if (uprv_memcmp((char *)&tziKey, (char*)&tziReg, sizeof(tziKey)) == 0) {                const UChar* icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);                if (U_SUCCESS(status)) {                    icuid = (char*)uprv_malloc(sizeof(char) * (len + 1));                    uprv_memset(icuid, 0, len + 1);                    u_austrncpy(icuid, icuTZ, len);                }            }        }        ures_close(winTZ);        if (icuid != NULL) {            break;        }    }    ures_close(bundle);    return icuid;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:64,


示例26: testTag

//.........这里部分代码省略.........            actual_bundle = i;        expected_resource_status = U_MISSING_RESOURCE_ERROR;        for (j=e_te_IN; j>=e_Root; --j)        {            if (is_in[j] && param[i].inherits[j])            {                if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */                    expected_resource_status = U_ZERO_ERROR;                else if(j == 0)                    expected_resource_status = U_USING_DEFAULT_WARNING;                else                    expected_resource_status = U_USING_FALLBACK_WARNING;                log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>.  actual_bundle=%s/n",                            param[i].name,                             i,                            frag,                            j,                            is_in[j]?"Yes":"No",                            j,                            param[i].inherits[j]?"Yes":"No",                            param[actual_bundle].name);                break;            }        }        for (j=param[i].where; j>=0; --j)        {            if (is_in[j])            {                if(base != NULL) {                    free(base);                    base = NULL;                }                base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1));                u_uastrcpy(base,NAME[j]);                break;            }            else {                if(base != NULL) {                    free(base);                    base = NULL;                }                base = (UChar*) malloc(sizeof(UChar) * 1);                *base = 0x0000;            }        }        /*-------------------------------------------------------------------- */        /* string */        strcpy(tag,"string_");        strcat(tag,frag);        strcpy(action,param[i].name);        strcat(action, ".ures_get(" );        strcat(action,tag);        strcat(action, ")");        string=    kERROR;        status = U_ZERO_ERROR;        ures_getStringByKey(theBundle, tag, &resultLen, &status);        if(U_SUCCESS(status))        {            status = U_ZERO_ERROR;            string=ures_getStringByKey(theBundle, tag, &resultLen, &status);        }        log_verbose("%s got %d, expected %d/n", action, status, expected_resource_status);        CONFIRM_ErrorCode(status, expected_resource_status);        if(U_SUCCESS(status)){            expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 3));            u_strcpy(expected_string,base);        }        else        {            expected_string = (UChar*)malloc(sizeof(UChar)*(u_strlen(kERROR) + 1));            u_strcpy(expected_string,kERROR);        }        CONFIRM_EQ(string, expected_string);        free(expected_string);        ures_close(theBundle);    }    free(base);    return (UBool)(passNum == pass);}
开发者ID:icu-project,项目名称:icu4c,代码行数:101,


示例27: TestConstruction1

void TestConstruction1(){    UResourceBundle *test1 = 0, *test2 = 0;    const UChar *result1, *result2;    int32_t resultLen;    UChar temp[7];    UErrorCode   err = U_ZERO_ERROR;    const char* testdatapath ;    const char*      locale="te_IN";    log_verbose("Testing ures_open()....../n");    testdatapath=loadTestData(&err);    if(U_FAILURE(err))    {        log_data_err("Could not load testdata.dat %s /n",myErrorName(err));        return;    }    test1=ures_open(testdatapath, NULL, &err);    if(U_FAILURE(err))    {        log_err("construction of %s did not succeed :  %s /n",NULL, myErrorName(err));        return;    }    test2=ures_open(testdatapath, locale, &err);    if(U_FAILURE(err))    {        log_err("construction of %s did not succeed :  %s /n",locale, myErrorName(err));        return;    }    result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &resultLen, &err);    result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &resultLen, &err);    if (U_FAILURE(err)) {        log_err("Something threw an error in TestConstruction(): %s/n", myErrorName(err));        return;    }    u_uastrcpy(temp, "TE_IN");    if(u_strcmp(result2, temp)!=0)    {        int n;        log_err("Construction test failed for ures_open();/n");        if(!getTestOption(VERBOSITY_OPTION))            log_info("(run verbose for more information)/n");        log_verbose("/nGot->");        for(n=0;result2[n];n++)        {            log_verbose("%04X ",result2[n]);        }        log_verbose("</n");        log_verbose("/nWant>");        for(n=0;temp[n];n++)        {            log_verbose("%04X ",temp[n]);        }        log_verbose("</n");    }    log_verbose("for string_in_Root_te_te_IN, default.txt had  %s/n", austrdup(result1));    log_verbose("for string_in_Root_te_te_IN, te_IN.txt had %s/n", austrdup(result2));    /* Test getVersionNumber*/    log_verbose("Testing version number/n");    log_verbose("for getVersionNumber :  %s/n", ures_getVersionNumber(test1));    ures_close(test1);    ures_close(test2);}
开发者ID:icu-project,项目名称:icu4c,代码行数:80,


示例28: u_UCharsToChars

UnicodeString& U_EXPORT2ZoneMeta::getCanonicalSystemID(const UnicodeString &tzid, UnicodeString &systemID, UErrorCode& status) {    int32_t len = tzid.length();    if ( len >= ZID_KEY_MAX ) {        status = U_ILLEGAL_ARGUMENT_ERROR;        systemID.remove();        return systemID;    }    char id[ZID_KEY_MAX];    const UChar* idChars = tzid.getBuffer();    u_UCharsToChars(idChars,id,len);    id[len] = (char) 0; // Make sure it is null terminated.    // replace '/' with ':'    char *p = id;    while (*p++) {        if (*p == '/') {            *p = ':';        }    }    UErrorCode tmpStatus = U_ZERO_ERROR;    UResourceBundle *top = ures_openDirect(NULL, gTimeZoneTypes, &tmpStatus);    UResourceBundle *rb = ures_getByKey(top, gTypeMapTag, NULL, &tmpStatus);    ures_getByKey(rb, gTimezoneTag, rb, &tmpStatus);    ures_getByKey(rb, id, rb, &tmpStatus);    if (U_SUCCESS(tmpStatus)) {        // direct map found        systemID.setTo(tzid);        ures_close(rb);        ures_close(top);        return systemID;    }    // If a map element not found, then look for an alias    tmpStatus = U_ZERO_ERROR;    ures_getByKey(top, gTypeAliasTag, rb, &tmpStatus);    ures_getByKey(rb, gTimezoneTag, rb, &tmpStatus);    const UChar *alias = ures_getStringByKey(rb,id,NULL,&tmpStatus);    if (U_SUCCESS(tmpStatus)) {        // alias found        ures_close(rb);        ures_close(top);        systemID.setTo(alias);        return systemID;    }    // Dereference the input ID using the tz data    const UChar *derefer = TimeZone::dereferOlsonLink(tzid);    if (derefer == NULL) {        systemID.remove();        status = U_ILLEGAL_ARGUMENT_ERROR;    } else {        len = u_strlen(derefer);        u_UCharsToChars(derefer,id,len);        id[len] = (char) 0; // Make sure it is null terminated.        // replace '/' with ':'        char *p = id;        while (*p++) {            if (*p == '/') {                *p = ':';            }        }        // If a dereference turned something up then look for an alias.        // rb still points to the alias table, so we don't have to go looking        // for it.        tmpStatus = U_ZERO_ERROR;        const UChar *alias = ures_getStringByKey(rb,id,NULL,&tmpStatus);        if (U_SUCCESS(tmpStatus)) {            // alias found            systemID.setTo(alias);        } else {            systemID.setTo(derefer);        }    }     ures_close(rb);     ures_close(top);     return systemID;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:86,


示例29: hasKey

 bool hasKey(const char* key) {   UErrorCode status = U_ZERO_ERROR;   ures_getStringByKey(bundle_, key, NULL, &status);   return U_SUCCESS(status); }
开发者ID:LeMaker,项目名称:android-actions,代码行数:5,



注:本文中的ures_getStringByKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ures_open函数代码示例
C++ ures_getStringByIndex函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。