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

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

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

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

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

示例1: ucnvsel_next_encoding

static const char* U_CALLCONV ucnvsel_next_encoding(UEnumeration* enumerator,                                                 int32_t* resultLength,                                                 UErrorCode* status) {  // check if already failed  if (U_FAILURE(*status)) {    return NULL;  }  int16_t cur = ((Enumerator*)(enumerator->context))->cur;  const UConverterSelector* sel;  const char* result;  if (cur >= ((Enumerator*)(enumerator->context))->length) {    return NULL;  }  sel = ((Enumerator*)(enumerator->context))->sel;  result = sel->encodings[((Enumerator*)(enumerator->context))->index[cur] ];  ((Enumerator*)(enumerator->context))->cur++;  if (resultLength) {    *resultLength = (int32_t)uprv_strlen(result);  }  return result;}
开发者ID:icu-project,项目名称:icu4c,代码行数:22,


示例2: getLongPathname

U_CAPI const char * U_EXPORT2getLongPathname(const char *pathname) {#if U_PLATFORM_USES_ONLY_WIN32_API    /* anticipate problems with "short" pathnames */    static WIN32_FIND_DATAA info;    HANDLE file=FindFirstFileA(pathname, &info);    if(file!=INVALID_HANDLE_VALUE) {        if(info.cAlternateFileName[0]!=0) {            /* this file has a short name, get and use the long one */            const char *basename=findBasename(pathname);            if(basename!=pathname) {                /* prepend the long filename with the original path */                uprv_memmove(info.cFileName+(basename-pathname), info.cFileName, uprv_strlen(info.cFileName)+1);                uprv_memcpy(info.cFileName, pathname, basename-pathname);            }            pathname=info.cFileName;        }        FindClose(file);    }#endif    return pathname;}
开发者ID:Akesure,项目名称:jxcore,代码行数:22,


示例3: u_uastrcpy

U_CAPI UChar*  U_EXPORT2u_uastrcpy(UChar *ucs1,          const char *s2 ){  UErrorCode err = U_ZERO_ERROR;  UConverter *cnv = u_getDefaultConverter(&err);  if(U_SUCCESS(err) && cnv != NULL) {    ucnv_toUChars(cnv,                    ucs1,                    MAX_STRLEN,                    s2,                    uprv_strlen(s2),                    &err);    u_releaseDefaultConverter(cnv);    if(U_FAILURE(err)) {      *ucs1 = 0;    }  } else {    *ucs1 = 0;  }  return ucs1;}
开发者ID:andrewleech,项目名称:firebird,代码行数:22,


示例4: writeValueAliases

 int32_t writeValueAliases(const Value &value, UErrorCode &errorCode) {     int32_t nameOffset=uhash_geti(nameGroupToOffset, (void *)value.joinedAliases);     if(nameOffset!=0) {         // The same list of aliases has been written already.         return nameOffset-1;  // Was incremented to reserve 0 for "not found".     }     // Write this not-yet-seen list of aliases.     nameOffset=nameGroups.length();     uhash_puti(nameGroupToOffset, (void *)value.joinedAliases,                nameOffset+1, &errorCode);     // The first byte tells us how many aliases there are.     // We use only values 0..0x1f in the first byte because when we write     // the name groups as an invariant-character string into a source file,     // those values (C0 control codes) are written as numbers rather than as characters.     int32_t count=value.count;     if(count>=0x20) {         fprintf(stderr, "Error: Too many aliases in /"%s/"/n", value.joinedAliases);         exit(U_INDEX_OUTOFBOUNDS_ERROR);     }     nameGroups.append((char)count, errorCode);     // There is at least a short name (sometimes empty) and a long name. (count>=2)     // Note: Sometimes the short and long names are the same.     // In such a case, we could set a flag and omit the duplicate,     // but that would save only about 1.35% of total data size (Unicode 6.0/ICU 4.6)     // which is not worth the trouble.     // Note: In Unicode 6.1, there are more duplicates due to newly added     // short names for blocks and other properties.     // It might now be worth changing the data structure.     for(int32_t i=0; i<count; ++i) {         const char *s=value.aliases[i];         int32_t sLength=uprv_strlen(s)+1;         if(sLength>maxNameLength) {             maxNameLength=sLength;         }         nameGroups.append(s, sLength, errorCode);  // including NUL     }     return nameOffset; }
开发者ID:icu-project,项目名称:icu-tools,代码行数:38,


示例5: ucasemap_mapUTF8

U_CFUNC int32_tucasemap_mapUTF8(const UCaseMap *csm,                 uint8_t *dest, int32_t destCapacity,                 const uint8_t *src, int32_t srcLength,                 UTF8CaseMapper *stringCaseMapper,                 UErrorCode *pErrorCode) {    int32_t destLength;    /* check argument values */    if(U_FAILURE(*pErrorCode)) {        return 0;    }    if( destCapacity<0 ||        (dest==NULL && destCapacity>0) ||        src==NULL ||        srcLength<-1    ) {        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;        return 0;    }    /* get the string length */    if(srcLength==-1) {        srcLength=(int32_t)uprv_strlen((const char *)src);    }    /* check for overlapping source and destination */    if( dest!=NULL &&        ((src>=dest && src<(dest+destCapacity)) ||         (dest>=src && dest<(src+srcLength)))    ) {        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;        return 0;    }    destLength=stringCaseMapper(csm, dest, destCapacity, src, srcLength, pErrorCode);    return u_terminateChars((char *)dest, destCapacity, destLength, pErrorCode);}
开发者ID:119120119,项目名称:node,代码行数:38,


示例6: allocString

static char *allocString(StringBlock *block, const char *s, int32_t length) {    uint32_t top;    char *p;    if(length<0) {        length=(int32_t)uprv_strlen(s);    }    /*     * add 1 for the terminating NUL     * and round up (+1 &~1)     * to keep the addresses on a 16-bit boundary     */    top=block->top + (uint32_t)((length + 1 + 1) & ~1);    if(top >= block->max) {        fprintf(stderr, "%s:%d: error: out of memory/n", path, lineNum);        exit(U_MEMORY_ALLOCATION_ERROR);    }    /* get the pointer and copy the string */    p = block->store + block->top;    uprv_memcpy(p, s, length);    p[length] = 0; /* NUL-terminate it */    if((length & 1) == 0) {        p[length + 1] = 0; /* set the padding byte */    }    /* check for invariant characters now that we have a NUL-terminated string for easy output */    if(!uprv_isInvariantString(p, length)) {        fprintf(stderr, "%s:%d: error: the name %s contains not just invariant characters/n", path, lineNum, p);        exit(U_INVALID_TABLE_FORMAT);    }    block->top = top;    return p;}
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:38,


示例7: uprv_eastrncpy

U_INTERNAL uint8_t* U_EXPORT2uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n){  uint8_t *orig_dst = dst;  if(n==-1) {    n = uprv_strlen((const char*)src)+1; /* copy NUL */  }  /* copy non-null */  while(*src && n>0) {    char ch = ebcdicFromAscii[*(src++)];    if(ch == 0) {      ch = ebcdicFromAscii[0x3f]; /* questionmark (subchar) */    }    *(dst++) = ch;    n--;  }  /* pad */  while(n>0) {    *(dst++) = 0;    n--;  }  return orig_dst;}
开发者ID:119120119,项目名称:node,代码行数:24,


示例8: while

const char *pkg_writeCharList(FileStream *s, CharList *l, const char *delim, int32_t quote){    char buffer[1024];    while(l != NULL)    {        if(l->str)        {            uprv_strncpy(buffer, l->str, 1023);            buffer[1023]=0;            if(uprv_strlen(l->str) >= 1023)            {                fprintf(stderr, "%s:%d: Internal error, line too long (greater than 1023 chars)/n",                        __FILE__, __LINE__);                exit(0);            }            if(quote < 0) { /* remove quotes */                if(buffer[uprv_strlen(buffer)-1] == '"') {                    buffer[uprv_strlen(buffer)-1] = '/0';                }                if(buffer[0] == '"') {                    uprv_strcpy(buffer, buffer+1);                }            } else if(quote > 0) { /* add quotes */                if(l->str[0] != '"') {                    uprv_strcpy(buffer, "/"");                    uprv_strcat(buffer, l->str);                }                if(l->str[uprv_strlen(l->str)-1] != '"') {                    uprv_strcat(buffer, "/"");                }            }            T_FileStream_write(s, buffer, (int32_t)uprv_strlen(buffer));        }        if(l->next && delim)        {            T_FileStream_write(s, delim, (int32_t)uprv_strlen(delim));        }        l = l->next;    }    return NULL;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:42,


示例9: uprv_detectWindowsTimeZone

//.........这里部分代码省略.........                    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;            }            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 = 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)) {                        /* Get the standard name from the registry key to compare with                           the one from Windows API call. */                        uprv_memset(regStdName, 0, sizeof(regStdName));                        result = getSTDName(winid, regStdName, sizeof(regStdName));                        if (result == ERROR_SUCCESS) {                            if (uprv_strcmp(apiStdName, regStdName) == 0) {                                idFound = TRUE;                            }                        }                        /* tmpid buffer holds the ICU timezone ID corresponding to the timezone ID from Windows.                         * If none is found, tmpid buffer will contain a fallback ID (i.e. the time zone ID matching                         * the current time zone information)                         */                        if (idFound || tmpid[0] == 0) {                            /* if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space) */                            int index=0;                            while (! (*icuTZ == '/0' || *icuTZ ==' ')) {                                tmpid[index++]=(char)(*icuTZ++);  /* safe to assume 'char' is ASCII compatible on windows */                            }                            tmpid[index]='/0';                        }                    }                }            }            ures_close(winTZ);            if (idFound) {                break;            }        }    }    /*     * Copy the timezone ID to icuid to be returned.     */    if (tmpid[0] != 0) {        len = uprv_strlen(tmpid);        icuid = (char*)uprv_calloc(len + 1, sizeof(char));        if (icuid != NULL) {            uprv_strcpy(icuid, tmpid);        }    }    ures_close(bundle);        return icuid;}
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:101,


示例10: main

//.........这里部分代码省略.........        char locale[64];        const char *thename = 0, *p, *q;        UBool fromICUData = FALSE;        arg = getLongPathname(argv[i]);        if (verbose) {            printf("processing bundle /"%s/"/n", argv[i]);        }        p = uprv_strrchr(arg, U_FILE_SEP_CHAR);#if U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR        if (p == NULL) {            p = uprv_strrchr(arg, U_FILE_ALT_SEP_CHAR);        }#endif        if (!p) {            p = arg;        } else {            p++;        }        q = uprv_strrchr(p, '.');        if (!q) {            for (q = p; *q; ++q)                ;        }        uprv_strncpy(locale, p, q - p);        locale[q - p] = 0;        if (!(fromICUData = !uprv_strcmp(inputDir, "-"))) {            UBool absfilename = *arg == U_FILE_SEP_CHAR;#ifdef U_WINDOWS            if (!absfilename) {                absfilename = (uprv_strlen(arg) > 2 && isalpha(arg[0])                    && arg[1] == ':' && arg[2] == U_FILE_SEP_CHAR);            }#endif            if (absfilename) {                thename = arg;            } else {                q = uprv_strrchr(arg, U_FILE_SEP_CHAR);#if U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR                if (q == NULL) {                    q = uprv_strrchr(arg, U_FILE_ALT_SEP_CHAR);                }#endif                uprv_strcpy(infile, inputDir);                if(q != NULL) {                    uprv_strcat(infile, U_FILE_SEP_STRING);                    strncat(infile, arg, q-arg);                }                thename = infile;            }        }        status = U_ZERO_ERROR;        if (thename) {            bundle = ures_openDirect(thename, locale, &status);        } else {            bundle = ures_open(fromICUData ? 0 : inputDir, locale, &status);        }        if (status == U_ZERO_ERROR) {            FILE *out;            const char *filename = 0;            const char *ext = 0;
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:66,


示例11: printOutBundle

static void printOutBundle(FILE *out, UConverter *converter, UResourceBundle *resource, int32_t indent, const char *pname, UErrorCode *status){    static const UChar cr[] = { '/n' };/*    int32_t noOfElements = ures_getSize(resource);*/    int32_t i = 0;    const char *key = ures_getKey(resource);    switch(ures_getType(resource)) {    case RES_STRING :        {            int32_t len=0;            const UChar* thestr = ures_getString(resource, &len, status);            UChar *string = quotedString(thestr);            /* TODO: String truncation */            if(trunc && len > truncsize) {                char msg[128];                printIndent(out, converter, indent);                sprintf(msg, "// WARNING: this resource, size %li is truncated to %li/n",                        (long)len, (long)(truncsize/2));                printCString(out, converter, msg, -1);                len = truncsize/2;            }            printIndent(out, converter, indent);            if(key != NULL) {                static const UChar openStr[] = { 0x0020, 0x007B, 0x0020, 0x0022 }; /* " { /"" */                static const UChar closeStr[] = { 0x0022, 0x0020, 0x007D }; /* "/" }" */                printCString(out, converter, key, (int32_t)uprv_strlen(key));                printString(out, converter, openStr, (int32_t)(sizeof(openStr)/sizeof(*openStr)));                printString(out, converter, string, len);                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));            } else {                static const UChar openStr[] = { 0x0022 }; /* "/"" */                static const UChar closeStr[] = { 0x0022, 0x002C }; /* "/"," */                printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));                printString(out, converter, string, (int32_t)(u_strlen(string)));                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));            }            if(verbose) {                printCString(out, converter, "// STRING", -1);            }            printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));            uprv_free(string);        }        break;    case RES_INT :        {            static const UChar openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0020, 0x007B, 0x0020 }; /* ":int { " */            static const UChar closeStr[] = { 0x0020, 0x007D }; /* " }" */            UChar num[20];            printIndent(out, converter, indent);            if(key != NULL) {                printCString(out, converter, key, -1);            }            printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));            uprv_itou(num, 20, ures_getInt(resource, status), 10, 0);            printString(out, converter, num, u_strlen(num));            printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));            if(verbose) {                printCString(out, converter, "// INT", -1);            }            printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));            break;        }    case RES_BINARY :        {            int32_t len = 0;            const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status);            if(trunc && len > truncsize) {                char msg[128];                printIndent(out, converter, indent);                sprintf(msg, "// WARNING: this resource, size %li is truncated to %li/n",                        (long)len, (long)(truncsize/2));                printCString(out, converter, msg, -1);                len = truncsize;            }            if(U_SUCCESS(*status)) {                static const UChar openStr[] = { 0x003A, 0x0062, 0x0069, 0x006E, 0x0061, 0x0072, 0x0079, 0x0020, 0x007B, 0x0020 }; /* ":binary { " */                static const UChar closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */                printIndent(out, converter, indent);                if(key != NULL) {                    printCString(out, converter, key, -1);                }                printString(out, converter, openStr, (int32_t)(sizeof(openStr) / sizeof(*openStr)));                for(i = 0; i<len; i++) {                    printHex(out, converter, *data++);                }                printString(out, converter, closeStr, (int32_t)(sizeof(closeStr) / sizeof(*closeStr)));                if(verbose) {                    printCString(out, converter, " // BINARY", -1);                }                printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));            } else {//.........这里部分代码省略.........
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,


示例12: convertFile

//.........这里部分代码省略.........            t = Transliterator::createInstance(translit, UTRANS_FORWARD, err);        }        if (U_FAILURE(err)) {            str.append((UChar32) 0);            initMsg(pname);            if (parse.line >= 0) {                UChar linebuf[20], offsetbuf[20];                uprv_itou(linebuf, 20, parse.line, 10, 0);                uprv_itou(offsetbuf, 20, parse.offset, 10, 0);                u_wmsg(stderr, "cantCreateTranslitParseErr", str.getBuffer(),                    u_wmsg_errorName(err), linebuf, offsetbuf);            } else {                u_wmsg(stderr, "cantCreateTranslit", str.getBuffer(),                    u_wmsg_errorName(err));            }            if (t) {                delete t;                t = 0;            }            goto error_exit;        }    }#endif    // Create codepage converter. If the codepage or its aliases weren't    // available, it returns NULL and a failure code. We also set the    // callbacks, and return errors in the same way.    convfrom = ucnv_open(fromcpage, &err);    if (U_FAILURE(err)) {        UnicodeString str(fromcpage, (int32_t)(uprv_strlen(fromcpage) + 1));        initMsg(pname);        u_wmsg(stderr, "cantOpenFromCodeset", str.getBuffer(),            u_wmsg_errorName(err));        goto error_exit;    }    ucnv_setToUCallBack(convfrom, toucallback, touctxt, 0, 0, &err);    if (U_FAILURE(err)) {        initMsg(pname);        u_wmsg(stderr, "cantSetCallback", u_wmsg_errorName(err));        goto error_exit;    }    convto = ucnv_open(tocpage, &err);    if (U_FAILURE(err)) {        UnicodeString str(tocpage, (int32_t)(uprv_strlen(tocpage) + 1));        initMsg(pname);        u_wmsg(stderr, "cantOpenToCodeset", str.getBuffer(),            u_wmsg_errorName(err));        goto error_exit;    }    ucnv_setFromUCallBack(convto, fromucallback, fromuctxt, 0, 0, &err);    if (U_FAILURE(err)) {        initMsg(pname);        u_wmsg(stderr, "cantSetCallback", u_wmsg_errorName(err));        goto error_exit;    }    ucnv_setFallback(convto, fallback);    // To ensure that the buffer always is of enough size, we    // must take the worst case scenario, that is the character in    // the codepage that uses the most bytes and multiply it against    // the buffer size.
开发者ID:gitpan,项目名称:ponie,代码行数:67,


示例13: ucnvsel_open

/* open a selector. If converterListSize is 0, build for all converters.   If excludedCodePoints is NULL, don't exclude any codepoints */U_CAPI UConverterSelector* U_EXPORT2ucnvsel_open(const char* const*  converterList, int32_t converterListSize,             const USet* excludedCodePoints,             const UConverterUnicodeSet whichSet, UErrorCode* status) {  // check if already failed  if (U_FAILURE(*status)) {    return NULL;  }  // ensure args make sense!  if (converterListSize < 0 || (converterList == NULL && converterListSize != 0)) {    *status = U_ILLEGAL_ARGUMENT_ERROR;    return NULL;  }  // allocate a new converter  LocalUConverterSelectorPointer newSelector(    (UConverterSelector*)uprv_malloc(sizeof(UConverterSelector)));  if (newSelector.isNull()) {    *status = U_MEMORY_ALLOCATION_ERROR;    return NULL;  }  uprv_memset(newSelector.getAlias(), 0, sizeof(UConverterSelector));  if (converterListSize == 0) {    converterList = NULL;    converterListSize = ucnv_countAvailable();  }  newSelector->encodings =    (char**)uprv_malloc(converterListSize * sizeof(char*));  if (!newSelector->encodings) {    *status = U_MEMORY_ALLOCATION_ERROR;    return NULL;  }  newSelector->encodings[0] = NULL;  // now we can call ucnvsel_close()  // make a backup copy of the list of converters  int32_t totalSize = 0;  int32_t i;  for (i = 0; i < converterListSize; i++) {    totalSize +=      (int32_t)uprv_strlen(converterList != NULL ? converterList[i] : ucnv_getAvailableName(i)) + 1;  }  // 4-align the totalSize to 4-align the size of the serialized form  int32_t encodingStrPadding = totalSize & 3;  if (encodingStrPadding != 0) {    encodingStrPadding = 4 - encodingStrPadding;  }  newSelector->encodingStrLength = totalSize += encodingStrPadding;  char* allStrings = (char*) uprv_malloc(totalSize);  if (!allStrings) {    *status = U_MEMORY_ALLOCATION_ERROR;    return NULL;  }  for (i = 0; i < converterListSize; i++) {    newSelector->encodings[i] = allStrings;    uprv_strcpy(newSelector->encodings[i],                converterList != NULL ? converterList[i] : ucnv_getAvailableName(i));    allStrings += uprv_strlen(newSelector->encodings[i]) + 1;  }  while (encodingStrPadding > 0) {    *allStrings++ = 0;    --encodingStrPadding;  }  newSelector->ownEncodingStrings = TRUE;  newSelector->encodingsCount = converterListSize;  UPropsVectors *upvec = upvec_open((converterListSize+31)/32, status);  generateSelectorData(newSelector.getAlias(), upvec, excludedCodePoints, whichSet, status);  upvec_close(upvec);  if (U_FAILURE(*status)) {    return NULL;  }  return newSelector.orphan();}
开发者ID:JoeDoyle23,项目名称:node,代码行数:79,


示例14: main

extern intmain(int argc, char* argv[]) {#if !UCONFIG_NO_NORMALIZATION    char filename[300];#endif    const char *srcDir=NULL, *destDir=NULL, *suffix=NULL;    char *basename=NULL;    UErrorCode errorCode=U_ZERO_ERROR;    U_MAIN_INIT_ARGS(argc, argv);    /* preset then read command line options */    options[4].value=u_getDataDirectory();    options[5].value="";    options[6].value="3.0.0";    argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);    /* error handling, printing usage message */    if(argc<0) {        fprintf(stderr,            "error in command line argument /"%s/"/n",            argv[-argc]);    }    if(argc<0 || options[0].doesOccur || options[1].doesOccur) {        /*         * Broken into chucks because the C89 standard says the minimum         * required supported string length is 509 bytes.         */        fprintf(stderr,            "Usage: %s [-options] [suffix]/n"            "/n"            "Read the UnicodeData.txt file and other Unicode properties files and/n"            "create a binary file " U_ICUDATA_NAME "_" DATA_NAME "." DATA_TYPE " with the normalization data/n"            "/n",            argv[0]);        fprintf(stderr,            "Options:/n"            "/t-h or -? or --help  this usage text/n"            "/t-v or --verbose     verbose output/n"            "/t-c or --copyright   include a copyright notice/n"            "/t-u or --unicode     Unicode version, followed by the version like 3.0.0/n");        fprintf(stderr,            "/t-d or --destdir     destination directory, followed by the path/n"            "/t-s or --sourcedir   source directory, followed by the path/n"            "/tsuffix              suffix that is to be appended with a '-'/n"            "/t                    to the source file basenames before opening;/n"            "/t                    'gennorm new' will read UnicodeData-new.txt etc./n");        return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;    }    /* get the options values */    beVerbose=options[2].doesOccur;    haveCopyright=options[3].doesOccur;    srcDir=options[5].value;    destDir=options[4].value;    if(argc>=2) {        suffix=argv[1];    } else {        suffix=NULL;    }#if UCONFIG_NO_NORMALIZATION    fprintf(stderr,        "gennorm writes a dummy " U_ICUDATA_NAME "_" DATA_NAME "." DATA_TYPE        " because UCONFIG_NO_NORMALIZATION is set, /n"        "see icu/source/common/unicode/uconfig.h/n");    generateData(destDir);#else    setUnicodeVersion(options[6].value);    /* prepare the filename beginning with the source dir */    uprv_strcpy(filename, srcDir);    basename=filename+uprv_strlen(filename);    if(basename>filename && *(basename-1)!=U_FILE_SEP_CHAR) {        *basename++=U_FILE_SEP_CHAR;    }    /* initialize */    init();    /* process DerivedNormalizationProps.txt (name changed for Unicode 3.2, to <=31 characters) */    if(suffix==NULL) {        uprv_strcpy(basename, "DerivedNormalizationProps.txt");    } else {        uprv_strcpy(basename, "DerivedNormalizationProps");        basename[30]='-';        uprv_strcpy(basename+31, suffix);        uprv_strcat(basename+31, ".txt");    }    parseDerivedNormalizationProperties(filename, &errorCode, FALSE);    if(U_FAILURE(errorCode)) {        /* can be only U_FILE_ACCESS_ERROR - try filename from before Unicode 3.2 */        if(suffix==NULL) {            uprv_strcpy(basename, "DerivedNormalizationProperties.txt");        } else {            uprv_strcpy(basename, "DerivedNormalizationProperties");//.........这里部分代码省略.........
开发者ID:andrewleech,项目名称:firebird,代码行数:101,


示例15: TestFileStream

static void TestFileStream(void){    int32_t c = 0;    int32_t c1=0;    UErrorCode status = U_ZERO_ERROR;    const char* testdatapath = loadTestData(&status);    char* fileName = (char*) malloc(uprv_strlen(testdatapath) +10);    FileStream* stream = NULL;    /* these should not be closed */    FileStream* pStdin  = T_FileStream_stdin();    FileStream* pStdout = T_FileStream_stdout();    FileStream* pStderr = T_FileStream_stderr();    const char* testline = "This is a test line";    int32_t bufLen = (int32_t)strlen(testline)+10;    char* buf = (char*) malloc(bufLen);    int32_t retLen = 0;    if(pStdin==NULL){        log_err("failed to get T_FileStream_stdin()");    }    if(pStdout==NULL){        log_err("failed to get T_FileStream_stdout()");    }    if(pStderr==NULL){        log_err("failed to get T_FileStream_stderr()");    }    uprv_strcpy(fileName,testdatapath);    uprv_strcat(fileName,".dat");    stream = T_FileStream_open(fileName, "r");    if(stream==NULL){        log_data_err("T_FileStream_open failed to open %s/n",fileName);    } else {      if(!T_FileStream_file_exists(fileName)){        log_data_err("T_FileStream_file_exists failed to verify existence of %s /n",fileName);      }            retLen=T_FileStream_read(stream,&c,1);      if(retLen==0){        log_data_err("T_FileStream_read failed to read from %s /n",fileName);      }      retLen=0;      T_FileStream_rewind(stream);      T_FileStream_read(stream,&c1,1);      if(c!=c1){        log_data_err("T_FileStream_rewind failed to rewind %s /n",fileName);      }      T_FileStream_rewind(stream);      c1 = T_FileStream_peek(stream);      if(c!=c1){        log_data_err("T_FileStream_peek failed to peekd %s /n",fileName);      }      c = T_FileStream_getc(stream);      T_FileStream_ungetc(c,stream);      if(c!= T_FileStream_getc(stream)){        log_data_err("T_FileStream_ungetc failed to d %s /n",fileName);      }            if(T_FileStream_size(stream)<=0){        log_data_err("T_FileStream_size failed to d %s /n",fileName);      }      if(T_FileStream_error(stream)){        log_data_err("T_FileStream_error shouldn't have an error %s/n",fileName);      }      if(!T_FileStream_error(NULL)){        log_err("T_FileStream_error didn't get an error %s/n",fileName);      }      T_FileStream_putc(stream, 0x20);      if(!T_FileStream_error(stream)){        /*          Warning           writing to a read-only file may not consistently fail on all platforms          (e.g. HP-UX, FreeBSD, MacOSX)        */        log_verbose("T_FileStream_error didn't get an error when writing to a readonly file %s/n",fileName);      }      T_FileStream_close(stream);    }    /* test writing function */    stream=NULL;    uprv_strcpy(fileName,testdatapath);    uprv_strcat(fileName,".tmp");    stream = T_FileStream_open(fileName,"w+");    if(stream == NULL){        log_data_err("Could not open %s for writing/n",fileName);    } else {      c= '$';      T_FileStream_putc(stream,c);      T_FileStream_rewind(stream);      if(c != T_FileStream_getc(stream)){        log_data_err("T_FileStream_putc failed %s/n",fileName);      }      T_FileStream_rewind(stream);      T_FileStream_writeLine(stream,testline);      T_FileStream_rewind(stream);      T_FileStream_readLine(stream,buf,bufLen);      if(uprv_strncmp(testline, buf,uprv_strlen(buf))!=0){//.........这里部分代码省略.........
开发者ID:icu-project,项目名称:icu4c,代码行数:101,


示例16: writeCCode

U_CAPI void U_EXPORT2writeCCode(const char *filename, const char *destdir, const char *optName, const char *optFilename, char *outFilePath) {    uint32_t column = MAX_COLUMN;    char buffer[4096], entry[64];    FileStream *in, *out;    size_t i, length;    in=T_FileStream_open(filename, "rb");    if(in==NULL) {        fprintf(stderr, "genccode: unable to open input file %s/n", filename);        exit(U_FILE_ACCESS_ERROR);    }    if(optName != NULL) { /* prepend  'icudt28_' */      strcpy(entry, optName);      strcat(entry, "_");    } else {      entry[0] = 0;    }    getOutFilename(filename, destdir, buffer, entry+uprv_strlen(entry), ".c", optFilename);    if (outFilePath != NULL) {        uprv_strcpy(outFilePath, buffer);    }    out=T_FileStream_open(buffer, "w");    if(out==NULL) {        fprintf(stderr, "genccode: unable to open output file %s/n", buffer);        exit(U_FILE_ACCESS_ERROR);    }    /* turn dashes or dots in the entry name into underscores */    length=uprv_strlen(entry);    for(i=0; i<length; ++i) {        if(entry[i]=='-' || entry[i]=='.') {            entry[i]='_';        }    }#if U_PLATFORM == U_PF_OS400    /*    TODO: Fix this once the compiler implements this feature. Keep in sync with udatamem.c    This is here because this platform can't currently put    const data into the read-only pages of an object or    shared library (service program). Only strings are allowed in read-only    pages, so we use char * strings to store the data.    In order to prevent the beginning of the data from ever matching the    magic numbers we must still use the initial double.    [grhoten 4/24/2003]    */    sprintf(buffer,        "#ifndef IN_GENERATED_CCODE/n"        "#define IN_GENERATED_CCODE/n"        "#define U_DISABLE_RENAMING 1/n"        "#include /"unicode/umachine.h/"/n"        "#endif/n"        "U_CDECL_BEGIN/n"        "const struct {/n"        "    double bogus;/n"        "    const char *bytes; /n"        "} %s={ 0.0, /n",        entry);    T_FileStream_writeLine(out, buffer);    for(;;) {        length=T_FileStream_read(in, buffer, sizeof(buffer));        if(length==0) {            break;        }        for(i=0; i<length; ++i) {            column = write8str(out, (uint8_t)buffer[i], column);        }    }    T_FileStream_writeLine(out, "/"/n};/nU_CDECL_END/n");#else    /* Function renaming shouldn't be done in data */    sprintf(buffer,        "#ifndef IN_GENERATED_CCODE/n"        "#define IN_GENERATED_CCODE/n"        "#define U_DISABLE_RENAMING 1/n"        "#include /"unicode/umachine.h/"/n"        "#endif/n"        "U_CDECL_BEGIN/n"        "const struct {/n"        "    double bogus;/n"        "    uint8_t bytes[%ld]; /n"        "} %s={ 0.0, {/n",        (long)T_FileStream_size(in), entry);    T_FileStream_writeLine(out, buffer);    for(;;) {        length=T_FileStream_read(in, buffer, sizeof(buffer));        if(length==0) {            break;        }        for(i=0; i<length; ++i) {            column = write8(out, (uint8_t)buffer[i], column);        }//.........这里部分代码省略.........
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:101,


示例17: writeAssemblyCode

U_CAPI void U_EXPORT2writeAssemblyCode(const char *filename, const char *destdir, const char *optEntryPoint, const char *optFilename, char *outFilePath) {    uint32_t column = MAX_COLUMN;    char entry[64];    uint32_t buffer[1024];    char *bufferStr = (char *)buffer;    FileStream *in, *out;    size_t i, length;    in=T_FileStream_open(filename, "rb");    if(in==NULL) {        fprintf(stderr, "genccode: unable to open input file %s/n", filename);        exit(U_FILE_ACCESS_ERROR);    }    getOutFilename(filename, destdir, bufferStr, entry, ".S", optFilename);    out=T_FileStream_open(bufferStr, "w");    if(out==NULL) {        fprintf(stderr, "genccode: unable to open output file %s/n", bufferStr);        exit(U_FILE_ACCESS_ERROR);    }    if (outFilePath != NULL) {        uprv_strcpy(outFilePath, bufferStr);    }#ifdef WINDOWS_WITH_GNUC    /* Need to fix the file seperator character when using MinGW. */    swapFileSepChar(outFilePath, U_FILE_SEP_CHAR, '/');#endif    if(optEntryPoint != NULL) {        uprv_strcpy(entry, optEntryPoint);        uprv_strcat(entry, "_dat");    }    /* turn dashes or dots in the entry name into underscores */    length=uprv_strlen(entry);    for(i=0; i<length; ++i) {        if(entry[i]=='-' || entry[i]=='.') {            entry[i]='_';        }    }    sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].header,        entry, entry, entry, entry,        entry, entry, entry, entry);    T_FileStream_writeLine(out, bufferStr);    T_FileStream_writeLine(out, assemblyHeader[assemblyHeaderIndex].beginLine);    for(;;) {        length=T_FileStream_read(in, buffer, sizeof(buffer));        if(length==0) {            break;        }        if (length != sizeof(buffer)) {            /* pad with extra 0's when at the end of the file */            for(i=0; i < (length % sizeof(uint32_t)); ++i) {                buffer[length+i] = 0;            }        }        for(i=0; i<(length/sizeof(buffer[0])); i++) {            column = write32(out, buffer[i], column);        }    }    T_FileStream_writeLine(out, "/n");    sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].footer,        entry, entry, entry, entry,        entry, entry, entry, entry);    T_FileStream_writeLine(out, bufferStr);    if(T_FileStream_error(in)) {        fprintf(stderr, "genccode: file read error while generating from file %s/n", filename);        exit(U_FILE_ACCESS_ERROR);    }    if(T_FileStream_error(out)) {        fprintf(stderr, "genccode: file write error while generating from file %s/n", filename);        exit(U_FILE_ACCESS_ERROR);    }    T_FileStream_close(out);    T_FileStream_close(in);}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:86,


示例18: uprv_strlen

UnicodeString&LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale,                                          UnicodeString& result) const {  if (locale.isBogus()) {    result.setToBogus();    return result;  }  UnicodeString resultName;  const char* lang = locale.getLanguage();  if (uprv_strlen(lang) == 0) {    lang = "root";  }  const char* script = locale.getScript();  const char* country = locale.getCountry();  const char* variant = locale.getVariant();  UBool hasScript = uprv_strlen(script) > 0;  UBool hasCountry = uprv_strlen(country) > 0;  UBool hasVariant = uprv_strlen(variant) > 0;  if (dialectHandling == ULDN_DIALECT_NAMES) {    char buffer[ULOC_FULLNAME_CAPACITY];    do { // loop construct is so we can break early out of search      if (hasScript && hasCountry) {        ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", script, "_", country, (char *)0);        localeIdName(buffer, resultName);        if (!resultName.isBogus()) {          hasScript = FALSE;          hasCountry = FALSE;          break;        }      }      if (hasScript) {        ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", script, (char *)0);        localeIdName(buffer, resultName);        if (!resultName.isBogus()) {          hasScript = FALSE;          break;        }      }      if (hasCountry) {        ncat(buffer, ULOC_FULLNAME_CAPACITY, lang, "_", country, (char*)0);        localeIdName(buffer, resultName);        if (!resultName.isBogus()) {          hasCountry = FALSE;          break;        }      }    } while (FALSE);  }  if (resultName.isBogus() || resultName.isEmpty()) {    localeIdName(lang, resultName);  }  UnicodeString resultRemainder;  UnicodeString temp;  UErrorCode status = U_ZERO_ERROR;  if (hasScript) {    resultRemainder.append(scriptDisplayName(script, temp, TRUE));  }  if (hasCountry) {    appendWithSep(resultRemainder, regionDisplayName(country, temp, TRUE));  }  if (hasVariant) {    appendWithSep(resultRemainder, variantDisplayName(variant, temp, TRUE));  }  resultRemainder.findAndReplace(formatOpenParen, formatReplaceOpenParen);  resultRemainder.findAndReplace(formatCloseParen, formatReplaceCloseParen);  LocalPointer<StringEnumeration> e(locale.createKeywords(status));  if (e.isValid() && U_SUCCESS(status)) {    UnicodeString temp2;    char value[ULOC_KEYWORD_AND_VALUES_CAPACITY]; // sigh, no ULOC_VALUE_CAPACITY    const char* key;    while ((key = e->next((int32_t *)0, status)) != NULL) {      locale.getKeywordValue(key, value, ULOC_KEYWORD_AND_VALUES_CAPACITY, status);      if (U_FAILURE(status)) {        return result;      }      keyDisplayName(key, temp, TRUE);      temp.findAndReplace(formatOpenParen, formatReplaceOpenParen);      temp.findAndReplace(formatCloseParen, formatReplaceCloseParen);      keyValueDisplayName(key, value, temp2, TRUE);      temp2.findAndReplace(formatOpenParen, formatReplaceOpenParen);      temp2.findAndReplace(formatCloseParen, formatReplaceCloseParen);      if (temp2 != UnicodeString(value, -1, US_INV)) {        appendWithSep(resultRemainder, temp2);      } else if (temp != UnicodeString(key, -1, US_INV)) {        UnicodeString temp3;        keyTypeFormat.format(temp, temp2, temp3, status);        appendWithSep(resultRemainder, temp3);      } else {        appendWithSep(resultRemainder, temp)          .append((UChar)0x3d /* = */)          .append(temp2);      }    }  }//.........这里部分代码省略.........
开发者ID:119120119,项目名称:node,代码行数:101,


示例19: processFile

/* Process a file */static voidprocessFile(const char *filename, const char *cp, const char *inputDir, const char *outputDir, const char *packageName, UErrorCode *status) {    /*FileStream     *in           = NULL;*/    struct SRBRoot *data         = NULL;    UCHARBUF       *ucbuf        = NULL;    char           *rbname       = NULL;    char           *openFileName = NULL;    char           *inputDirBuf  = NULL;    char           outputFileName[256];    int32_t dirlen  = 0;    int32_t filelen = 0;    if (status==NULL || U_FAILURE(*status)) {        return;    }    if(filename==NULL){        *status=U_ILLEGAL_ARGUMENT_ERROR;        return;    }else{        filelen = (int32_t)uprv_strlen(filename);    }    if(inputDir == NULL) {        const char *filenameBegin = uprv_strrchr(filename, U_FILE_SEP_CHAR);        openFileName = (char *) uprv_malloc(dirlen + filelen + 2);        openFileName[0] = '/0';        if (filenameBegin != NULL) {            /*             * When a filename ../../../data/root.txt is specified,             * we presume that the input directory is ../../../data             * This is very important when the resource file includes             * another file, like UCARules.txt or thaidict.brk.             */            int32_t filenameSize = (int32_t)(filenameBegin - filename + 1);            inputDirBuf = uprv_strncpy((char *)uprv_malloc(filenameSize), filename, filenameSize);            /* test for NULL */            if(inputDirBuf == NULL) {                *status = U_MEMORY_ALLOCATION_ERROR;                goto finish;            }            inputDirBuf[filenameSize - 1] = 0;            inputDir = inputDirBuf;            dirlen  = (int32_t)uprv_strlen(inputDir);        }    }else{        dirlen  = (int32_t)uprv_strlen(inputDir);        if(inputDir[dirlen-1] != U_FILE_SEP_CHAR) {            openFileName = (char *) uprv_malloc(dirlen + filelen + 2);            /* test for NULL */            if(openFileName == NULL) {                *status = U_MEMORY_ALLOCATION_ERROR;                goto finish;            }            openFileName[0] = '/0';            /*             * append the input dir to openFileName if the first char in             * filename is not file seperation char and the last char input directory is  not '.'.             * This is to support :             * genrb -s. /home/icu/data             * genrb -s. icu/data             * The user cannot mix notations like             * genrb -s. /icu/data --- the absolute path specified. -s redundant             * user should use             * genrb -s. icu/data  --- start from CWD and look in icu/data dir             */            if( (filename[0] != U_FILE_SEP_CHAR) && (inputDir[dirlen-1] !='.')){                uprv_strcpy(openFileName, inputDir);                openFileName[dirlen]     = U_FILE_SEP_CHAR;            }            openFileName[dirlen + 1] = '/0';        } else {            openFileName = (char *) uprv_malloc(dirlen + filelen + 1);            /* test for NULL */            if(openFileName == NULL) {                *status = U_MEMORY_ALLOCATION_ERROR;                goto finish;            }            uprv_strcpy(openFileName, inputDir);        }    }    uprv_strcat(openFileName, filename);    ucbuf = ucbuf_open(openFileName, &cp,getShowWarning(),TRUE, status);    if(*status == U_FILE_ACCESS_ERROR) {        fprintf(stderr, "couldn't open file %s/n", openFileName == NULL ? filename : openFileName);        goto finish;    }//.........这里部分代码省略.........
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:101,


示例20: make_res_filename

/* Generate the target .res file name from the input file name */static char*make_res_filename(const char *filename,                  const char *outputDir,                  const char *packageName,                  UErrorCode *status) {    char *basename;    char *dirname;    char *resName;    int32_t pkgLen = 0; /* length of package prefix */    if (U_FAILURE(*status)) {        return 0;    }    if(packageName != NULL)    {        pkgLen = (int32_t)(1 + uprv_strlen(packageName));    }    /* setup */    basename = dirname = resName = 0;    /* determine basename, and compiled file names */    basename = (char*) uprv_malloc(sizeof(char) * (uprv_strlen(filename) + 1));    if(basename == 0) {        *status = U_MEMORY_ALLOCATION_ERROR;        goto finish;    }    get_basename(basename, filename);    dirname = (char*) uprv_malloc(sizeof(char) * (uprv_strlen(filename) + 1));    if(dirname == 0) {        *status = U_MEMORY_ALLOCATION_ERROR;        goto finish;    }    get_dirname(dirname, filename);    if (outputDir == NULL) {        /* output in same dir as .txt */        resName = (char*) uprv_malloc(sizeof(char) * (uprv_strlen(dirname)                                      + pkgLen                                      + uprv_strlen(basename)                                      + uprv_strlen(RES_SUFFIX) + 8));        if(resName == 0) {            *status = U_MEMORY_ALLOCATION_ERROR;            goto finish;        }        uprv_strcpy(resName, dirname);        if(packageName != NULL)        {            uprv_strcat(resName, packageName);            uprv_strcat(resName, "_");        }        uprv_strcat(resName, basename);    } else {        int32_t dirlen      = (int32_t)uprv_strlen(outputDir);        int32_t basenamelen = (int32_t)uprv_strlen(basename);        resName = (char*) uprv_malloc(sizeof(char) * (dirlen + pkgLen + basenamelen + 8));        if (resName == NULL) {            *status = U_MEMORY_ALLOCATION_ERROR;            goto finish;        }        uprv_strcpy(resName, outputDir);        if(outputDir[dirlen] != U_FILE_SEP_CHAR) {            resName[dirlen]     = U_FILE_SEP_CHAR;            resName[dirlen + 1] = '/0';        }        if(packageName != NULL)        {            uprv_strcat(resName, packageName);            uprv_strcat(resName, "_");        }        uprv_strcat(resName, basename);    }finish:    uprv_free(basename);    uprv_free(dirname);    return resName;}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:95,


示例21: ARRAY_SIZE

U_NAMESPACE_BEGIN#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])int32_t CharsetRecog_2022::match_2022(const uint8_t *text, int32_t textLen, const uint8_t escapeSequences[][5], int32_t escapeSequences_length){    int32_t i, j;    int32_t escN;    int32_t hits   = 0;    int32_t misses = 0;    int32_t shifts = 0;    int32_t quality;    i = 0;    while(i < textLen) {        if(text[i] == 0x1B) {            escN = 0;            while(escN < escapeSequences_length) {                const uint8_t *seq = escapeSequences[escN];                int32_t seq_length = uprv_strlen((const char *) seq);                if (textLen-i >= seq_length) {                    j = 1;                    while(j < seq_length) {                        if(seq[j] != text[i+j]) {                            goto checkEscapes;                        }                        j += 1;                    }                    hits += 1;                    i += seq_length-1;                    goto scanInput;                }                // else we ran out of string to compare this time.checkEscapes:                escN += 1;            }            misses += 1;        }        if( text[i]== 0x0e || text[i] == 0x0f){            shifts += 1;        }scanInput:        i += 1;    }    if (hits == 0) {        return 0;    }    //    // Initial quality is based on relative proportion of recongized vs.    //   unrecognized escape sequences.     //   All good:  quality = 100;    //   half or less good: quality = 0;    //   linear inbetween.    quality = (100*hits - 100*misses) / (hits + misses);    // Back off quality if there were too few escape sequences seen.    //   Include shifts in this computation, so that KR does not get penalized    //   for having only a single Escape sequence, but many shifts.    if (hits+shifts < 5) {        quality -= (5-(hits+shifts))*10;    }    if (quality < 0) {        quality = 0;    }    return quality;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:76,


示例22: parseFlagsFile

/* * Opens the given fileName and reads in the information storing the data in flagBuffer. */U_CAPI int32_t U_EXPORT2parseFlagsFile(const char *fileName, char **flagBuffer, int32_t flagBufferSize, const char ** flagNames, int32_t numOfFlags, UErrorCode *status) {    char* buffer = NULL;    char* tmpFlagBuffer = NULL;    UBool allocateMoreSpace = FALSE;    int32_t idx, i;    int32_t result = 0;    FileStream *f = T_FileStream_open(fileName, "r");    if (f == NULL) {        *status = U_FILE_ACCESS_ERROR;        goto parseFlagsFile_cleanup;    }        buffer = uprv_malloc(sizeof(char) * currentBufferSize);    tmpFlagBuffer = uprv_malloc(sizeof(char) * flagBufferSize);    if (buffer == NULL || tmpFlagBuffer == NULL) {        *status = U_MEMORY_ALLOCATION_ERROR;        goto parseFlagsFile_cleanup;    }    do {        if (allocateMoreSpace) {            allocateMoreSpace = FALSE;            currentBufferSize *= 2;            uprv_free(buffer);            buffer = uprv_malloc(sizeof(char) * currentBufferSize);            if (buffer == NULL) {                *status = U_MEMORY_ALLOCATION_ERROR;                goto parseFlagsFile_cleanup;            }        }        for (i = 0; i < numOfFlags;) {            if (T_FileStream_readLine(f, buffer, currentBufferSize) == NULL) {                /* End of file reached. */                break;            }            if (buffer[0] == '#') {                continue;            }            if (uprv_strlen(buffer) == (currentBufferSize - 1) && buffer[currentBufferSize-2] != '/n') {                /* Allocate more space for buffer if it didnot read the entrire line */                allocateMoreSpace = TRUE;                T_FileStream_rewind(f);                break;            } else {                idx = extractFlag(buffer, currentBufferSize, tmpFlagBuffer, flagBufferSize, flagNames, numOfFlags, status);                if (U_FAILURE(*status)) {                    if (*status == U_BUFFER_OVERFLOW_ERROR) {                        result = currentBufferSize;                    } else {                        result = -1;                    }                    break;                } else {                    if (flagNames != NULL) {                        if (idx >= 0) {                            uprv_strcpy(flagBuffer[idx], tmpFlagBuffer);                        } else {                            /* No match found.  Skip it. */                            continue;                        }                    } else {                        uprv_strcpy(flagBuffer[i++], tmpFlagBuffer);                    }                }            }        }    } while (allocateMoreSpace && U_SUCCESS(*status));parseFlagsFile_cleanup:    uprv_free(tmpFlagBuffer);    uprv_free(buffer);    T_FileStream_close(f);        if (U_FAILURE(*status)) {        return -1;    }    if (U_SUCCESS(*status) && result == 0) {        currentBufferSize = DEFAULT_BUFFER_SIZE;    }    return result;}
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:91,


示例23: uhash_hashIChars

U_CAPI int32_t U_EXPORT2uhash_hashIChars(const UHashTok key) {    STRING_HASH(uint8_t, key.pointer, uprv_strlen((char*)p), uprv_tolower(*p));}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:4,


示例24: ucnvsel_openFromSerialized

//.........这里部分代码省略.........    pHeader->info.dataFormat[1] == 0x53 &&    pHeader->info.dataFormat[2] == 0x65 &&    pHeader->info.dataFormat[3] == 0x6c  )) {    /* header not valid or dataFormat not recognized */    *status = U_INVALID_FORMAT_ERROR;    return NULL;  }  if (pHeader->info.formatVersion[0] != 1) {    *status = U_UNSUPPORTED_ERROR;    return NULL;  }  uint8_t* swapped = NULL;  if (pHeader->info.isBigEndian != U_IS_BIG_ENDIAN ||      pHeader->info.charsetFamily != U_CHARSET_FAMILY  ) {    // swap the data    UDataSwapper *ds =      udata_openSwapperForInputData(p, length, U_IS_BIG_ENDIAN, U_CHARSET_FAMILY, status);    int32_t totalSize = ucnvsel_swap(ds, p, -1, NULL, status);    if (U_FAILURE(*status)) {      udata_closeSwapper(ds);      return NULL;    }    if (length < totalSize) {      udata_closeSwapper(ds);      *status = U_INDEX_OUTOFBOUNDS_ERROR;      return NULL;    }    swapped = (uint8_t*)uprv_malloc(totalSize);    if (swapped == NULL) {      udata_closeSwapper(ds);      *status = U_MEMORY_ALLOCATION_ERROR;      return NULL;    }    ucnvsel_swap(ds, p, length, swapped, status);    udata_closeSwapper(ds);    if (U_FAILURE(*status)) {      uprv_free(swapped);      return NULL;    }    p = swapped;    pHeader = (const DataHeader *)p;  }  if (length < (pHeader->dataHeader.headerSize + 16 * 4)) {    // not even enough space for the header and the indexes    uprv_free(swapped);    *status = U_INDEX_OUTOFBOUNDS_ERROR;    return NULL;  }  p += pHeader->dataHeader.headerSize;  length -= pHeader->dataHeader.headerSize;  // indexes  const int32_t *indexes = (const int32_t *)p;  if (length < indexes[UCNVSEL_INDEX_SIZE]) {    uprv_free(swapped);    *status = U_INDEX_OUTOFBOUNDS_ERROR;    return NULL;  }  p += UCNVSEL_INDEX_COUNT * 4;  // create and populate the selector object  UConverterSelector* sel = (UConverterSelector*)uprv_malloc(sizeof(UConverterSelector));  char **encodings =    (char **)uprv_malloc(      indexes[UCNVSEL_INDEX_NAMES_COUNT] * sizeof(char *));  if (sel == NULL || encodings == NULL) {    uprv_free(swapped);    uprv_free(sel);    uprv_free(encodings);    *status = U_MEMORY_ALLOCATION_ERROR;    return NULL;  }  uprv_memset(sel, 0, sizeof(UConverterSelector));  sel->pvCount = indexes[UCNVSEL_INDEX_PV_COUNT];  sel->encodings = encodings;  sel->encodingsCount = indexes[UCNVSEL_INDEX_NAMES_COUNT];  sel->encodingStrLength = indexes[UCNVSEL_INDEX_NAMES_LENGTH];  sel->swapped = swapped;  // trie  sel->trie = utrie2_openFromSerialized(UTRIE2_16_VALUE_BITS,                                        p, indexes[UCNVSEL_INDEX_TRIE_SIZE], NULL,                                        status);  p += indexes[UCNVSEL_INDEX_TRIE_SIZE];  if (U_FAILURE(*status)) {    ucnvsel_close(sel);    return NULL;  }  // bit vectors  sel->pv = (uint32_t *)p;  p += sel->pvCount * 4;  // encoding names  char* s = (char*)p;  for (int32_t i = 0; i < sel->encodingsCount; ++i) {    sel->encodings[i] = s;    s += uprv_strlen(s) + 1;  }  p += sel->encodingStrLength;  return sel;}
开发者ID:JoeDoyle23,项目名称:node,代码行数:101,


示例25: printConverters

static int printConverters(const char *pname, const char *lookfor,    int canon){    UErrorCode err = U_ZERO_ERROR;    int32_t num;    uint16_t num_stds;    const char **stds;    /* If there is a specified name, just handle that now. */    if (lookfor) {        if (!canon) {            printf("%s/n", lookfor);            return 0;        } else {        /*  Because we are printing a canonical name, we need the            true converter name. We've done that already except for            the default name (because we want to print the exact            name one would get when calling ucnv_getDefaultName()            in non-canon mode). But since we do not know at this            point if we have the default name or something else, we            need to normalize again to the canonical converter            name. */            const char *truename = ucnv_getAlias(lookfor, 0, &err);            if (U_SUCCESS(err)) {                lookfor = truename;            } else {                err = U_ZERO_ERROR;            }        }    }    /* Print converter names. We come here for one of two reasons: we       are printing all the names (lookfor was null), or we have a       single converter to print but in canon mode, hence we need to       get to it in order to print everything. */    num = ucnv_countAvailable();    if (num <= 0) {        initMsg(pname);        u_wmsg(stderr, "cantGetNames");        return -1;    }    if (lookfor) {        num = 1;                /* We know where we want to be. */    }    num_stds = ucnv_countStandards();    stds = (const char **) uprv_malloc(num_stds * sizeof(*stds));    if (!stds) {        u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(U_MEMORY_ALLOCATION_ERROR));        return -1;    } else {        uint16_t s;        for (s = 0; s < num_stds; ++s) {            stds[s] = ucnv_getStandard(s, &err);            if (U_FAILURE(err)) {                u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(err));                return -1;            }        }    }    for (int32_t i = 0; i < num; i++) {        const char *name;        uint16_t num_aliases;        /* Set the name either to what we are looking for, or        to the current converter name. */        if (lookfor) {            name = lookfor;        } else {            name = ucnv_getAvailableName(i);        }        /* Get all the aliases associated to the name. */        err = U_ZERO_ERROR;        num_aliases = ucnv_countAliases(name, &err);        if (U_FAILURE(err)) {            printf("%s", name);            UnicodeString str(name, (int32_t)(uprv_strlen(name) + 1));            putchar('/t');            u_wmsg(stderr, "cantGetAliases", str.getBuffer(),                u_wmsg_errorName(err));            return -1;        } else {            uint16_t a, s, t;            /* Write all the aliases and their tags. */            for (a = 0; a < num_aliases; ++a) {                const char *alias = ucnv_getAlias(name, a, &err);                if (U_FAILURE(err)) {                    UnicodeString str(name, (int32_t)(uprv_strlen(name) + 1));//.........这里部分代码省略.........
开发者ID:gitpan,项目名称:ponie,代码行数:101,



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


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