这篇教程C++ u_errorName函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中u_errorName函数的典型用法代码示例。如果您正苦于以下问题:C++ u_errorName函数的具体用法?C++ u_errorName怎么用?C++ u_errorName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了u_errorName函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: drivervoidStringCaseTest::TestCasing() { UErrorCode status = U_ZERO_ERROR;#if !UCONFIG_NO_BREAK_ITERATION LocalUBreakIteratorPointer iter;#endif char cLocaleID[100]; UnicodeString locale, input, output, optionsString, result; uint32_t options; int32_t whichCase, type; LocalPointer<TestDataModule> driver(TestDataModule::getTestDataModule("casing", *this, status)); if(U_SUCCESS(status)) { for(whichCase=0; whichCase<TEST_COUNT; ++whichCase) {#if UCONFIG_NO_BREAK_ITERATION if(whichCase==TEST_TITLE) { continue; }#endif LocalPointer<TestData> casingTest(driver->createTestData(dataNames[whichCase], status)); if(U_FAILURE(status)) { errln("TestCasing failed to createTestData(%s) - %s", dataNames[whichCase], u_errorName(status)); break; } const DataMap *myCase = NULL; while(casingTest->nextCase(myCase, status)) { input = myCase->getString("Input", status); output = myCase->getString("Output", status); if(whichCase!=TEST_FOLD) { locale = myCase->getString("Locale", status); } locale.extract(0, 0x7fffffff, cLocaleID, sizeof(cLocaleID), "");#if !UCONFIG_NO_BREAK_ITERATION if(whichCase==TEST_TITLE) { type = myCase->getInt("Type", status); if(type>=0) { iter.adoptInstead(ubrk_open((UBreakIteratorType)type, cLocaleID, NULL, 0, &status)); } else if(type==-2) { // Open a trivial break iterator that only delivers { 0, length } // or even just { 0 } as boundaries. static const UChar rules[] = { 0x2e, 0x2a, 0x3b }; // ".*;" UParseError parseError; iter.adoptInstead(ubrk_openRules(rules, UPRV_LENGTHOF(rules), NULL, 0, &parseError, &status)); } }#endif options = 0; if(whichCase==TEST_TITLE || whichCase==TEST_FOLD) { optionsString = myCase->getString("Options", status); if(optionsString.indexOf((UChar)0x54)>=0) { // T options|=U_FOLD_CASE_EXCLUDE_SPECIAL_I; } if(optionsString.indexOf((UChar)0x4c)>=0) { // L options|=U_TITLECASE_NO_LOWERCASE; } if(optionsString.indexOf((UChar)0x41)>=0) { // A options|=U_TITLECASE_NO_BREAK_ADJUSTMENT; } } if(U_FAILURE(status)) { dataerrln("error: TestCasing() setup failed for %s test case from casing.res: %s", dataNames[whichCase], u_errorName(status)); status = U_ZERO_ERROR; } else {#if UCONFIG_NO_BREAK_ITERATION LocalPointer<UMemory> iter;#endif TestCasingImpl(input, output, whichCase, iter.getAlias(), cLocaleID, options); }#if !UCONFIG_NO_BREAK_ITERATION iter.adoptInstead(NULL);#endif } } }#if !UCONFIG_NO_BREAK_ITERATION // more tests for API coverage status=U_ZERO_ERROR; input=UNICODE_STRING_SIMPLE("sTrA//u00dfE").unescape(); (result=input).toTitle(NULL); if(result!=UNICODE_STRING_SIMPLE("Stra//u00dfe").unescape()) { dataerrln("UnicodeString::toTitle(NULL) failed."); }#endif}
开发者ID:Acorld,项目名称:WinObjC-Heading,代码行数:88,
示例2: readHexCodeUnitU_CDECL_ENDstatic UCharreadHexCodeUnit(const char **string, UErrorCode *status){ UChar result = 0; int32_t value = 0; char c; int32_t noDigits = 0; while((c = **string) != 0 && noDigits < 4) { if( c >= '0' && c <= '9') { value = c - '0'; } else if ( c >= 'a' && c <= 'f') { value = c - 'a' + 10; } else if ( c >= 'A' && c <= 'F') { value = c - 'A' + 10; } else { *status = U_ILLEGAL_ARGUMENT_ERROR;#ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: Bad hex char at '%s': %s/n", __FILE__, __LINE__, *string, u_errorName(*status));#endif return 0; } result = (result << 4) | (UChar)value; noDigits++; (*string)++; } // if the string was terminated before we read 4 digits, set an error if(noDigits < 4) { *status = U_ILLEGAL_ARGUMENT_ERROR;#ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: Short (only %d digits, wanted 4) at '%s': %s/n", __FILE__, __LINE__, noDigits,*string, u_errorName(*status));#endif } return result;}
开发者ID:MIPS,项目名称:external-icu,代码行数:37,
示例3: ifvoid CollationThaiTest::compareArray(Collator& c, const char* tests[], int32_t testsLength) { for (int32_t i = 0; i < testsLength; i += 3) { Collator::EComparisonResult expect; if (tests[i+1][0] == '<') { expect = Collator::LESS; } else if (tests[i+1][0] == '>') { expect = Collator::GREATER; } else if (tests[i+1][0] == '=') { expect = Collator::EQUAL; } else { // expect = Integer.decode(tests[i+1]).intValue(); errln((UnicodeString)"Error: unknown operator " + tests[i+1]); return; } UnicodeString s1, s2; parseChars(s1, tests[i]); parseChars(s2, tests[i+2]); doTest(&c, s1, s2, expect);#if 0 UErrorCode status = U_ZERO_ERROR; int32_t result = c.compare(s1, s2); if (sign(result) != sign(expect)) { UnicodeString t1, t2; errln(UnicodeString("") + i/3 + ": compare(" + IntlTest::prettify(s1, t1) + " , " + IntlTest::prettify(s2, t2) + ") got " + result + "; expected " + expect); CollationKey k1, k2; c.getCollationKey(s1, k1, status); c.getCollationKey(s2, k2, status); if (U_FAILURE(status)) { errln((UnicodeString)"Fail: getCollationKey returned " + u_errorName(status)); return; } errln((UnicodeString)" key1: " + prettify(k1, t1) ); errln((UnicodeString)" key2: " + prettify(k2, t2) ); } else { // Collator.compare worked OK; now try the collation keys CollationKey k1, k2; c.getCollationKey(s1, k1, status); c.getCollationKey(s2, k2, status); if (U_FAILURE(status)) { errln((UnicodeString)"Fail: getCollationKey returned " + u_errorName(status)); return; } result = k1.compareTo(k2); if (sign(result) != sign(expect)) { UnicodeString t1, t2; errln(UnicodeString("") + i/3 + ": key(" + IntlTest::prettify(s1, t1) + ").compareTo(key(" + IntlTest::prettify(s2, t2) + ")) got " + result + "; expected " + expect); errln((UnicodeString)" " + prettify(k1, t1) + " vs. " + prettify(k2, t2)); } }#endif }}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:68,
示例4: pattern1void MessageFormatRegressionTest::Test4031438() { UErrorCode status = U_ZERO_ERROR; UnicodeString pattern1("Impossible {1} has occurred -- status code is {0} and message is {2}."); UnicodeString pattern2("Double '' Quotes {0} test and quoted '{1}' test plus 'other {2} stuff'."); MessageFormat *messageFormatter = new MessageFormat("", status); failure(status, "new MessageFormat"); const UBool possibleDataError = TRUE; //try { logln("Apply with pattern : " + pattern1); messageFormatter->applyPattern(pattern1, status); failure(status, "messageFormat->applyPattern"); //Object[] params = {new Integer(7)}; Formattable params []= { Formattable((int32_t)7) }; UnicodeString tempBuffer; FieldPosition pos(FieldPosition::DONT_CARE); tempBuffer = messageFormatter->format(params, 1, tempBuffer, pos, status); if(tempBuffer != "Impossible {1} has occurred -- status code is 7 and message is {2}." || failure(status, "MessageFormat::format")) dataerrln("Tests arguments < substitution failed"); logln("Formatted with 7 : " + tempBuffer); ParsePosition pp(0); int32_t count = 0; Formattable *objs = messageFormatter->parse(tempBuffer, pp, count); //if(objs[7/*params.length*/] != NULL) // errln("Parse failed with more than expected arguments"); NumberFormat *fmt = 0; UnicodeString temp, temp1; for (int i = 0; i < count; i++) { // convert to string if not already Formattable obj = objs[i]; temp.remove(); if(obj.getType() == Formattable::kString) temp = obj.getString(temp); else { fmt = NumberFormat::createInstance(status); switch (obj.getType()) { case Formattable::kLong: fmt->format(obj.getLong(), temp); break; case Formattable::kInt64: fmt->format(obj.getInt64(), temp); break; case Formattable::kDouble: fmt->format(obj.getDouble(), temp); break; default: break; } } // convert to string if not already Formattable obj1 = params[i]; temp1.remove(); if(obj1.getType() == Formattable::kString) temp1 = obj1.getString(temp1); else { fmt = NumberFormat::createInstance(status); switch (obj1.getType()) { case Formattable::kLong: fmt->format(obj1.getLong(), temp1); break; case Formattable::kInt64: fmt->format(obj1.getInt64(), temp1); break; case Formattable::kDouble: fmt->format(obj1.getDouble(), temp1); break; default: break; } } //if (objs[i] != NULL && objs[i].getString(temp1) != params[i].getString(temp2)) { if (temp != temp1) { errln("Parse failed on object " + objs[i].getString(temp1) + " at index : " + i); } } delete fmt; delete [] objs; // {sfb} does this apply? no way to really pass a null Formattable, // only a null array /*tempBuffer = messageFormatter->format(null, tempBuffer, FieldPosition(FieldPosition::DONT_CARE), status); if (tempBuffer != "Impossible {1} has occurred -- status code is {0} and message is {2}." || failure(status, "messageFormat->format")) errln("Tests with no arguments failed"); logln("Formatted with null : " + tempBuffer);*/ logln("Apply with pattern : " + pattern2); messageFormatter->applyPattern(pattern2, status); failure(status, "messageFormatter->applyPattern", possibleDataError); tempBuffer.remove(); tempBuffer = messageFormatter->format(params, 1, tempBuffer, pos, status); if (tempBuffer != "Double ' Quotes 7 test and quoted {1} test plus other {2} stuff.") dataerrln("quote format test (w/ params) failed. - %s", u_errorName(status)); logln("Formatted with params : " + tempBuffer); /*tempBuffer = messageFormatter->format(null); if (!tempBuffer.equals("Double ' Quotes {0} test and quoted {1} test plus other {2} stuff.")) errln("quote format test (w/ null) failed."); logln("Formatted with null : " + tempBuffer); logln("toPattern : " + messageFormatter.toPattern());*/ /*} catch (Exception foo) { errln("Exception when formatting in bug 4031438. "+foo.getMessage()); }*///.........这里部分代码省略.........
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,
示例5: loglnvoid CanonicalIteratorTest::TestBasic() { UErrorCode status = U_ZERO_ERROR; static const char * const testArray[][2] = { {"//u00C5d//u0307//u0327", "A//u030Ad//u0307//u0327, A//u030Ad//u0327//u0307, A//u030A//u1E0B//u0327, " "A//u030A//u1E11//u0307, //u00C5d//u0307//u0327, //u00C5d//u0327//u0307, " "//u00C5//u1E0B//u0327, //u00C5//u1E11//u0307, //u212Bd//u0307//u0327, " "//u212Bd//u0327//u0307, //u212B//u1E0B//u0327, //u212B//u1E11//u0307"}, {"//u010d//u017E", "c//u030Cz//u030C, c//u030C//u017E, //u010Dz//u030C, //u010D//u017E"}, {"x//u0307//u0327", "x//u0307//u0327, x//u0327//u0307, //u1E8B//u0327"}, }; #if 0 // This is not interesting for C/C++ as the data is already built beforehand // check build UnicodeSet ss = CanonicalIterator.getSafeStart(); logln("Safe Start: " + ss.toPattern(true)); ss = CanonicalIterator.getStarts('a'); expectEqual("Characters with 'a' at the start of their decomposition: ", "", CanonicalIterator.getStarts('a'), new UnicodeSet("[/u00E0-/u00E5/u0101/u0103/u0105/u01CE/u01DF/u01E1/u01FB" + "/u0201/u0203/u0227/u1E01/u1EA1/u1EA3/u1EA5/u1EA7/u1EA9/u1EAB/u1EAD/u1EAF/u1EB1/u1EB3/u1EB5/u1EB7]") );#endif // check permute // NOTE: we use a TreeSet below to sort the output, which is not guaranteed to be sorted! Hashtable *permutations = new Hashtable(FALSE, status); permutations->setValueDeleter(uhash_deleteUnicodeString); UnicodeString toPermute("ABC"); CanonicalIterator::permute(toPermute, FALSE, permutations, status); logln("testing permutation"); expectEqual("Simple permutation ", "", collectionToString(permutations), "ABC, ACB, BAC, BCA, CAB, CBA"); delete permutations; // try samples logln("testing samples"); Hashtable *set = new Hashtable(FALSE, status); set->setValueDeleter(uhash_deleteUnicodeString); int32_t i = 0; CanonicalIterator it("", status); if(U_SUCCESS(status)) { for (i = 0; i < ARRAY_LENGTH(testArray); ++i) { //logln("Results for: " + name.transliterate(testArray[i])); UnicodeString testStr = CharsToUnicodeString(testArray[i][0]); it.setSource(testStr, status); set->removeAll(); for (;;) { //UnicodeString *result = new UnicodeString(it.next()); UnicodeString result(it.next()); if (result.isBogus()) { break; } set->put(result, new UnicodeString(result), status); // Add result to the table //logln(++counter + ": " + hex.transliterate(result)); //logln(" = " + name.transliterate(result)); } expectEqual(i + ": ", testStr, collectionToString(set), CharsToUnicodeString(testArray[i][1])); } } else { dataerrln("Couldn't instantiate canonical iterator. Error: %s", u_errorName(status)); } delete set;}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:70,
示例6: reportErrorvoid reportError(UErrorCode *status) { u_fprintf(outerr, "Error %d(%s) : %U happened!/n", *status, u_errorName(*status), getErrorName(*status));}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:3,
示例7: testDataextern inttestData(TestIDNA& test) { char *basename=NULL; UErrorCode errorCode=U_ZERO_ERROR; char *saveBasename =NULL; profile = usprep_open(NULL, DATA_NAME, &errorCode); if(U_FAILURE(errorCode)){ test.errln("Failed to load IDNA data file. " + UnicodeString(u_errorName(errorCode))); return errorCode; } char* filename = (char*) malloc(strlen(IntlTest::pathToDataDirectory())*1024); //TODO get the srcDir dynamically const char *srcDir=IntlTest::pathToDataDirectory(); idnTrie = &profile->sprepTrie; indexes = profile->indexes; mappingData = profile->mappingData; //initialize pTestIDNA = &test; /* prepare the filename beginning with the source dir */ if(uprv_strchr(srcDir,U_FILE_SEP_CHAR) == NULL){ filename[0] = 0x2E; filename[1] = U_FILE_SEP_CHAR; uprv_strcpy(filename+2,srcDir); }else{ uprv_strcpy(filename, srcDir); } basename=filename+uprv_strlen(filename); if(basename>filename && *(basename-1)!=U_FILE_SEP_CHAR) { *basename++=U_FILE_SEP_CHAR; } /* process unassigned */ basename=filename+uprv_strlen(filename); if(basename>filename && *(basename-1)!=U_FILE_SEP_CHAR) { *basename++=U_FILE_SEP_CHAR; } /* first copy misc directory */ saveBasename = basename; uprv_strcpy(basename,MISC_DIR); basename = basename + uprv_strlen(MISC_DIR); *basename++=U_FILE_SEP_CHAR; /* process unassigned */ uprv_strcpy(basename,fileNames[0]); parseMappings(filename,TRUE, test,&errorCode); if(U_FAILURE(errorCode)) { test.errln( "Could not open file %s for reading /n", filename); return errorCode; } testAllCodepoints(test); usprep_close(profile); pTestIDNA = NULL; free(filename); return errorCode;}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:63,
示例8: UnicodeStringvoid TransliteratorAPITest::TestTransliterate2(){ //testing tranliterate(String text, int start, int limit, StringBuffer result) UnicodeString Data2[]={ //ID, input string, start, limit, transliterated string "Any-Hex", "hello! How are you?", "0", "5", UnicodeString("//u0068//u0065//u006C//u006C//u006F", ""), UnicodeString("//u0068//u0065//u006C//u006C//u006F! How are you?", "") , "Any-Hex", "hello! How are you?", "7", "12", UnicodeString("//u0048//u006F//u0077//u0020//u0061", ""), UnicodeString("hello! //u0048//u006F//u0077//u0020//u0061re you?", ""), "Hex-Any", CharsToUnicodeString("//u0068//u0065//u006C//u006C//u006F//u0021//u0020"), "0", "5", "hello", "hello! " , // "Contracted-Expanded", CharsToUnicodeString("//u00C0//u00C1//u0042"), "1", "2", CharsToUnicodeString("//u0041//u0301"), CharsToUnicodeString("//u00C0//u0041//u0301//u0042") , "Devanagari-Latin", CharsToUnicodeString("//u092D//u093E//u0930//u0924"), "0", "1", "bha", CharsToUnicodeString("bha//u093E//u0930//u0924") , "Devanagari-Latin", CharsToUnicodeString("//u092D//u093E//u0930//u0924"), "1", "2", CharsToUnicodeString("//u0314//u0101"), CharsToUnicodeString("//u092D//u0314//u0101//u0930//u0924") }; logln("/n Testing transliterate(String, int, int, StringBuffer)"); Transliterator* t; UnicodeString gotResBuf; UnicodeString temp; int32_t start, limit; UErrorCode status = U_ZERO_ERROR; UParseError parseError; for(uint32_t i=0; i<UPRV_LENGTHOF(Data2); i=i+6){ t=Transliterator::createInstance(Data2[i+0], UTRANS_FORWARD, parseError, status); if(t==0){ dataerrln("FAIL: construction: " + prettify(Data2[i+0]) + " - " + u_errorName(status)); continue; } start=getInt(Data2[i+2]); limit=getInt(Data2[i+3]); Data2[i+1].extractBetween(start, limit, gotResBuf); t->transliterate(gotResBuf); // errln("FAIL: calling transliterate on " + t->getID()); doTest(t->getID() + ".transliterate(UnicodeString, int32_t, int32_t, UnicodeString):(" + start + "," + limit + ") for /n/t source: " + prettify(Data2[i+1]), gotResBuf, Data2[i+4]); temp=Data2[i+1]; t->transliterate(temp, start, limit); doTest(t->getID() + ".transliterate(Replaceable, int32_t, int32_t, ):(" + start + "," + limit + ") for /n/t source: " + prettify(Data2[i+1]), temp, Data2[i+5]); status = U_ZERO_ERROR; callEverything(t, __LINE__); delete t; t = NULL; } status = U_ZERO_ERROR; logln("/n Try calling transliterate with illegal start and limit values"); t=Transliterator::createInstance("Any-Hex", UTRANS_FORWARD, parseError, status); if(U_FAILURE(status)) { errln("Error creating transliterator %s", u_errorName(status)); delete t; return; } gotResBuf = temp = "try start greater than limit"; t->transliterate(gotResBuf, 10, 5); if(gotResBuf == temp) { logln("OK: start greater than limit value handled correctly"); } else { errln("FAIL: start greater than limit value returned" + gotResBuf); } callEverything(t, __LINE__); delete t;}
开发者ID:icu-project,项目名称:icu4c,代码行数:62,
示例9: verifyMappingvoidTimeZoneBoundaryTest::TestBoundaries(){ UErrorCode status = U_ZERO_ERROR; TimeZone* pst = TimeZone::createTimeZone("PST"); Calendar* tempcal = Calendar::createInstance(pst, status); if(U_SUCCESS(status)) { verifyMapping(*tempcal, 1997, Calendar::APRIL, 3, 0, 238904.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 4, 0, 238928.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 5, 0, 238952.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 5, 23, 238975.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 6, 0, 238976.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 6, 1, 238977.0); verifyMapping(*tempcal, 1997, Calendar::APRIL, 6, 3, 238978.0); } else { dataerrln("Could not create calendar. Error: %s", u_errorName(status)); } TimeZone* utc = TimeZone::createTimeZone("UTC"); Calendar* utccal = Calendar::createInstance(utc, status); if(U_SUCCESS(status)) { verifyMapping(*utccal, 1997, Calendar::APRIL, 6, 0, 238968.0); } else { dataerrln("Could not create calendar. Error: %s", u_errorName(status)); } TimeZone* save = TimeZone::createDefault(); TimeZone::setDefault(*pst); if (tempcal != NULL) { // DST changeover for PST is 4/6/1997 at 2 hours past midnight // at 238978.0 epoch hours. tempcal->clear(); tempcal->set(1997, Calendar::APRIL, 6); UDate d = tempcal->getTime(status); // i is minutes past midnight standard time for (int i=-120; i<=180; i+=60) { UBool inDST = (i >= 120); tempcal->setTime(d + i*60*1000, status); verifyDST(tempcal->getTime(status),pst, TRUE, inDST, -8*ONE_HOUR,inDST ? -7*ONE_HOUR : -8*ONE_HOUR); } } TimeZone::setDefault(*save); delete save; delete utccal; delete tempcal;#if 1 { logln("--- Test a ---"); UDate d = date(97, UCAL_APRIL, 6); TimeZone *z = TimeZone::createTimeZone("PST"); for (int32_t i = 60; i <= 180; i += 15) { UBool inDST = (i >= 120); UDate e = d + i * 60 * 1000; verifyDST(e, z, TRUE, inDST, - 8 * ONE_HOUR, inDST ? - 7 * ONE_HOUR: - 8 * ONE_HOUR); } delete z; }#endif#if 1 { logln("--- Test b ---"); TimeZone *tz; TimeZone::setDefault(*(tz = TimeZone::createTimeZone("PST"))); delete tz; logln("========================================"); findDaylightBoundaryUsingDate(date(97, 0, 1), "PST", PST_1997_BEG); logln("========================================"); findDaylightBoundaryUsingDate(date(97, 6, 1), "PDT", PST_1997_END); }#endif#if 1 { logln("--- Test c ---"); logln("========================================"); TimeZone* z = TimeZone::createTimeZone("Australia/Adelaide"); findDaylightBoundaryUsingTimeZone(date(97, 0, 1), TRUE, 859653000000.0, z); logln("========================================"); findDaylightBoundaryUsingTimeZone(date(97, 6, 1), FALSE, 877797000000.0, z); delete z; }#endif#if 1 { logln("--- Test d ---"); logln("========================================"); findDaylightBoundaryUsingTimeZone(date(97, 0, 1), FALSE, PST_1997_BEG); logln("========================================"); findDaylightBoundaryUsingTimeZone(date(97, 6, 1), TRUE, PST_1997_END); }#endif#if 0 { logln("--- Test e ---"); TimeZone *z = TimeZone::createDefault(); logln(UnicodeString("") + z->getOffset(1, 97, 3, 4, 6, 0) + " " + date(97, 3, 4)); logln(UnicodeString("") + z->getOffset(1, 97, 3, 5, 7, 0) + " " + date(97, 3, 5)); logln(UnicodeString("") + z->getOffset(1, 97, 3, 6, 1, 0) + " " + date(97, 3, 6)); logln(UnicodeString("") + z->getOffset(1, 97, 3, 7, 2, 0) + " " + date(97, 3, 7));//.........这里部分代码省略.........
开发者ID:harrykipper,项目名称:Alcatel_OT_985_kernel,代码行数:101,
示例10: mainint main( void ){ UFILE *out; UErrorCode status = U_ZERO_ERROR; out = u_finit(stdout, NULL, NULL); if(!out) { fprintf(stderr, "Could not initialize (finit()) over stdout! /n"); return 1; } ucnv_setFromUCallBack(u_fgetConverter(out), UCNV_FROM_U_CALLBACK_ESCAPE, NULL, NULL, NULL, &status); if(U_FAILURE(status)) { u_fprintf(out, "Warning- couldn't set the substitute callback - err %s/n", u_errorName(status)); } /* End Demo boilerplate */ u_fprintf(out,"ICU Case Mapping Sample Program/n/n"); u_fprintf(out, "C++ Case Mapping/n/n"); UnicodeString string("This is a test"); /* lowercase = "istanbul" */ UChar lowercase[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0}; /* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */ UChar uppercase[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0}; UnicodeString upper(uppercase); UnicodeString lower(lowercase); u_fprintf(out, "/nstring: "); printUnicodeString(out, string); string.toUpper(); /* string = "THIS IS A TEST" */ u_fprintf(out, "/ntoUpper(): "); printUnicodeString(out, string); string.toLower(); /* string = "this is a test" */ u_fprintf(out, "/ntoLower(): "); printUnicodeString(out, string); u_fprintf(out, "/n/nlowercase=%S, uppercase=%S/n", lowercase, uppercase); string = upper; string.toLower(Locale("tr", "TR")); /* Turkish lower case map string = lowercase */ u_fprintf(out, "/nupper.toLower: "); printUnicodeString(out, string); string = lower; string.toUpper(Locale("tr", "TR")); /* Turkish upper case map string = uppercase */ u_fprintf(out, "/nlower.toUpper: "); printUnicodeString(out, string); u_fprintf(out, "/nEnd C++ sample/n/n"); // Call the C version int rc = c_main(out); u_fclose(out); return rc;}
开发者ID:cyrusimap,项目名称:icu4c,代码行数:61,
示例11: strprepProfileLineFnstatic void U_CALLCONVstrprepProfileLineFn(void *context, char *fields[][2], int32_t fieldCount, UErrorCode *pErrorCode) { uint32_t mapping[40]; char *end, *map; uint32_t code; int32_t length; /*UBool* mapWithNorm = (UBool*) context;*/ const char* typeName; uint32_t rangeStart=0,rangeEnd =0; const char* filename = (const char*) context; const char *s; s = u_skipWhitespace(fields[0][0]); if (*s == '@') { /* special directive */ s++; length = fields[0][1] - s; if (length >= NORMALIZE_DIRECTIVE_LEN && uprv_strncmp(s, NORMALIZE_DIRECTIVE, NORMALIZE_DIRECTIVE_LEN) == 0) { options[NORMALIZE].doesOccur = TRUE; return; } else if (length >= CHECK_BIDI_DIRECTIVE_LEN && uprv_strncmp(s, CHECK_BIDI_DIRECTIVE, CHECK_BIDI_DIRECTIVE_LEN) == 0) { options[CHECK_BIDI].doesOccur = TRUE; return; } else { fprintf(stderr, "gensprep error parsing a directive %s.", fields[0][0]); } } typeName = fields[2][0]; map = fields[1][0]; if(uprv_strstr(typeName, usprepTypeNames[USPREP_UNASSIGNED])!=NULL){ u_parseCodePointRange(s, &rangeStart,&rangeEnd, pErrorCode); if(U_FAILURE(*pErrorCode)){ fprintf(stderr, "Could not parse code point range. Error: %s/n",u_errorName(*pErrorCode)); return; } /* store the range */ storeRange(rangeStart,rangeEnd,USPREP_UNASSIGNED, pErrorCode); }else if(uprv_strstr(typeName, usprepTypeNames[USPREP_PROHIBITED])!=NULL){ u_parseCodePointRange(s, &rangeStart,&rangeEnd, pErrorCode); if(U_FAILURE(*pErrorCode)){ fprintf(stderr, "Could not parse code point range. Error: %s/n",u_errorName(*pErrorCode)); return; } /* store the range */ storeRange(rangeStart,rangeEnd,USPREP_PROHIBITED, pErrorCode); }else if(uprv_strstr(typeName, usprepTypeNames[USPREP_MAP])!=NULL){ /* get the character code, field 0 */ code=(uint32_t)uprv_strtoul(s, &end, 16); if(end<=s || end!=fields[0][1]) { fprintf(stderr, "gensprep: syntax error in field 0 at %s/n", fields[0][0]); *pErrorCode=U_PARSE_ERROR; exit(U_PARSE_ERROR); } /* parse the mapping string */ length=u_parseCodePoints(map, mapping, sizeof(mapping)/4, pErrorCode); /* store the mapping */ storeMapping(code,mapping, length,USPREP_MAP, pErrorCode); }else{ *pErrorCode = U_INVALID_FORMAT_ERROR; } if(U_FAILURE(*pErrorCode)) { fprintf(stderr, "gensprep error parsing %s line %s at %s. Error: %s/n",filename, fields[0][0],fields[2][0],u_errorName(*pErrorCode)); exit(*pErrorCode); }}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:86,
示例12: parseNormalizationCorrectionsstatic voidparseNormalizationCorrections(const char *filename, UErrorCode *pErrorCode) { char *fields[4][2]; if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { return; } u_parseDelimitedFile(filename, ';', fields, 4, normalizationCorrectionsLineFn, NULL, pErrorCode); /* fprintf(stdout,"Number of code points that have NormalizationCorrections mapping with length >1 : %i/n",len); */ if(U_FAILURE(*pErrorCode) && ( *pErrorCode!=U_FILE_ACCESS_ERROR)) { fprintf(stderr, "gensprep error: u_parseDelimitedFile(/"%s/") failed - %s/n", filename, u_errorName(*pErrorCode)); exit(*pErrorCode); }}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:17,
示例13: mainextern intmain(int argc, char* argv[]) {#if !UCONFIG_NO_IDNA char* filename = NULL;#endif const char *srcDir=NULL, *destDir=NULL, *icuUniDataDir=NULL; const char *bundleName=NULL, *inputFileName = NULL; char *basename=NULL; int32_t sprepOptions = 0; UErrorCode errorCode=U_ZERO_ERROR; U_MAIN_INIT_ARGS(argc, argv); /* preset then read command line options */ options[DESTDIR].value=u_getDataDirectory(); options[SOURCEDIR].value=""; options[UNICODE_VERSION].value="0"; /* don't assume the unicode version */ options[BUNDLE_NAME].value = DATA_NAME; options[NORMALIZE].value = ""; argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options); /* error handling, printing usage message */ if(argc<0) { fprintf(stderr, "error in command line argument /"%s/"/n", argv[-argc]); } if(argc<0 || options[HELP].doesOccur || options[HELP_QUESTION_MARK].doesOccur) { return printHelp(argc, argv); } /* get the options values */ beVerbose=options[VERBOSE].doesOccur; haveCopyright=options[COPYRIGHT].doesOccur; srcDir=options[SOURCEDIR].value; destDir=options[DESTDIR].value; bundleName = options[BUNDLE_NAME].value; if(options[NORMALIZE].doesOccur) { icuUniDataDir = options[NORMALIZE].value; } else { icuUniDataDir = options[NORM_CORRECTION_DIR].value; } if(argc<2) { /* print the help message */ return printHelp(argc, argv); } else { inputFileName = argv[1]; } if(!options[UNICODE_VERSION].doesOccur){ return printHelp(argc, argv); } if(options[ICUDATADIR].doesOccur) { u_setDataDirectory(options[ICUDATADIR].value); }#if UCONFIG_NO_IDNA fprintf(stderr, "gensprep writes dummy " U_ICUDATA_NAME "_" DATA_NAME "." DATA_TYPE " because UCONFIG_NO_IDNA is set, /n" "see icu/source/common/unicode/uconfig.h/n"); generateData(destDir, bundleName);#else setUnicodeVersion(options[UNICODE_VERSION].value); filename = (char* ) uprv_malloc(uprv_strlen(srcDir) + 300); /* hopefully this should be enough */ /* prepare the filename beginning with the source dir */ if(uprv_strchr(srcDir,U_FILE_SEP_CHAR) == NULL && uprv_strchr(srcDir,U_FILE_ALT_SEP_CHAR) == NULL){ filename[0] = '.'; filename[1] = U_FILE_SEP_CHAR; uprv_strcpy(filename+2,srcDir); }else{ 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 the file */ uprv_strcpy(basename,inputFileName); parseMappings(filename,FALSE, &errorCode); if(U_FAILURE(errorCode)) { fprintf(stderr, "Could not open file %s for reading. Error: %s /n", filename, u_errorName(errorCode)); return errorCode; } if(options[NORMALIZE].doesOccur){ /* this option might be set by @normalize;; in the source file */ /* set up directory for NormalizationCorrections.txt */ uprv_strcpy(filename,icuUniDataDir); basename=filename+uprv_strlen(filename);//.........这里部分代码省略.........
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:101,
示例14: SWAPWU_NAMESPACE_BEGINle_uint32 LookupProcessor::applyLookupTable(const LEReferenceTo<LookupTable> &lookupTable, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const{ if (LE_FAILURE(success)) { return 0; } le_uint16 lookupType = SWAPW(lookupTable->lookupType); le_uint16 subtableCount = SWAPW(lookupTable->subTableCount); le_int32 startPosition = glyphIterator->getCurrStreamPosition(); le_uint32 delta; for (le_uint16 subtable = 0; subtable < subtableCount; subtable += 1) { LEReferenceTo<LookupSubtable> lookupSubtable = lookupTable->getLookupSubtable(lookupTable, subtable, success); delta = applySubtable(lookupSubtable, lookupType, glyphIterator, fontInstance, success); if (delta > 0 && LE_FAILURE(success)) {#if LE_TRACE _LETRACE("Posn #%d, type %X, applied subtable #%d/%d - %s/n", startPosition, lookupType, subtable, subtableCount, u_errorName((UErrorCode)success));#endif return 1; } glyphIterator->setCurrStreamPosition(startPosition); } return 1;}
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:30,
示例15: dataerrlnvoid TransliteratorAPITest::TestgetID() { UnicodeString trans="Latin-Greek"; UnicodeString ID; UParseError parseError; UErrorCode status = U_ZERO_ERROR; Transliterator* t= Transliterator::createInstance(trans, UTRANS_FORWARD, parseError, status); if(t==0 || U_FAILURE(status)){ dataerrln("FAIL: construction of Latin-Greek - %s",u_errorName(status)); return; }else{ ID= t->getID(); if(ID != trans) errln("FAIL: getID returned " + ID + " instead of Latin-Greek"); delete t; } int i; for (i=0; i<Transliterator::countAvailableIDs(); i++){ status = U_ZERO_ERROR; ID = (UnicodeString) Transliterator::getAvailableID(i); if(ID.indexOf("Thai")>-1){ continue; } t = Transliterator::createInstance(ID, UTRANS_FORWARD, parseError, status); if(t == 0){ errln("FAIL: " + ID); continue; } if(ID != t->getID()) errln("FAIL: getID() returned " + t->getID() + " instead of " + ID); delete t; } ID=(UnicodeString)Transliterator::getAvailableID(i); if(ID != (UnicodeString)Transliterator::getAvailableID(0)){ errln("FAIL: calling getAvailableID(index > coundAvailableIDs) should make index=0/n"); } Transliterator* t1=Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status); Transliterator* t2=Transliterator::createInstance("Latin-Greek", UTRANS_FORWARD, parseError, status); if(t1 ==0 || t2 == 0){ errln("FAIL: construction"); return; } Transliterator* t3=t1->clone(); Transliterator* t4=t2->clone(); if(t1->getID() != t3->getID() || t2->getID() != t4->getID() || t1->getID() == t4->getID() || t2->getID() == t3->getID() || t1->getID()== t4->getID() ) errln("FAIL: getID or clone failed"); Transliterator* t5=Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status); if(t5 == 0) errln("FAIL: construction"); else if(t1->getID() != t5->getID() || t5->getID() != t3->getID() || t1->getID() != t3->getID()) errln("FAIL: getID or clone failed"); delete t1; delete t2; delete t3; delete t4; delete t5;}
开发者ID:icu-project,项目名称:icu4c,代码行数:64,
示例16: errlnvoid TransliteratorAPITest::TestGetAdoptFilter(){ UErrorCode status = U_ZERO_ERROR; UParseError parseError; Transliterator *t=Transliterator::createInstance("Any-Hex", UTRANS_FORWARD, parseError, status); if(t == 0 || U_FAILURE(status)) { errln("Error creating transliterator %s", u_errorName(status)); delete t; return; } const UnicodeFilter *u=t->getFilter(); if(u != NULL){ errln("FAIL: getFilter failed. Didn't return null when the transliterator used no filtering"); delete t; return; } UnicodeString got, temp, message; UnicodeString data="ABCabcbbCBa"; temp = data; t->transliterate(temp); t->adoptFilter(new TestFilter1); got = data; t->transliterate(got); UnicodeString exp=UnicodeString("A//u0042Ca//u0062c//u0062//u0062C//u0042a", ""); message="transliteration after adoptFilter(a,A,c,C) "; doTest(message, got, exp); logln("Testing round trip"); t->adoptFilter((UnicodeFilter*)u); if(t->getFilter() == NULL) logln("OK: adoptFilter and getFilter round trip worked"); else errln("FAIL: adoptFilter or getFilter round trip failed"); got = data; t->transliterate(got); exp=UnicodeString("//u0041//u0042//u0043//u0061//u0062//u0063//u0062//u0062//u0043//u0042//u0061", ""); message="transliteration after adopting null filter"; doTest(message, got, exp); message="adoptFilter round trip"; doTest("adoptFilter round trip", got, temp); t->adoptFilter(new TestFilter2); callEverything(t, __LINE__); data="heelloe"; exp=UnicodeString("//u0068eell//u006Fe", ""); got = data; t->transliterate(got); message="transliteration using (e,l) filter"; doTest("transliteration using (e,l) filter", got, exp); data="are well"; exp=UnicodeString("//u0061//u0072e//u0020//u0077ell", ""); got = data; t->transliterate(got); doTest(message, got, exp); t->adoptFilter(new TestFilter3); data="ho, wow!"; exp=UnicodeString("//u0068o//u002C//u0020wow//u0021", ""); got = data; t->transliterate(got); message="transliteration using (o,w) filter"; doTest("transliteration using (o,w) filter", got, exp); data="owl"; exp=UnicodeString("ow//u006C", ""); got = data; t->transliterate(got); doTest("transliteration using (o,w) filter", got, exp); delete t;}
开发者ID:icu-project,项目名称:icu4c,代码行数:75,
示例17: parseMappingsU_CDECL_ENDstatic voidparseMappings(const char *filename,UBool reportError, TestIDNA& test, UErrorCode *pErrorCode) { char *fields[3][2]; if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { return; } u_parseDelimitedFile(filename, ';', fields, 3, strprepProfileLineFn, (void*)filename, pErrorCode); //fprintf(stdout,"Number of code points that have mappings with length >1 : %i/n",len); if(U_FAILURE(*pErrorCode) && (reportError || *pErrorCode!=U_FILE_ACCESS_ERROR)) { test.errln( "testidn error: u_parseDelimitedFile(/"%s/") failed - %s/n", filename, u_errorName(*pErrorCode)); }}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:18,
示例18: debugCB_fromUvoid debugCB_fromU(const void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode * err){ debugCBContext *ctx = (debugCBContext*)context; /*UConverterFromUCallback junkFrom;*/ #if DEBUG_TMI printf("debugCB_fromU: Context %p:%d called, reason %d on cnv %p [err=%s]/n", ctx, ctx->serial, reason, fromUArgs->converter, u_errorName(*err));#endif if(ctx->magic != 0xC0FFEE) { fprintf(stderr, "debugCB_fromU: Context %p:%d magic is 0x%x should be 0xC0FFEE./n", ctx,ctx->serial, ctx->magic); return; } if(reason == UCNV_CLONE) { /* see comments in above flagCB clone code */ UConverterFromUCallback saveCallback; const void *saveContext; debugCBContext *cloned; UErrorCode subErr = U_ZERO_ERROR; /* "recreate" it */#if DEBUG_TMI printf("debugCB_fromU: cloning../n");#endif cloned = debugCB_clone(ctx); if(cloned == NULL) { fprintf(stderr, "debugCB_fromU: internal clone failed on %p/n", ctx); *err = U_MEMORY_ALLOCATION_ERROR; return; } ucnv_setFromUCallBack(fromUArgs->converter, cloned->subCallback, cloned->subContext, &saveCallback, &saveContext, &subErr); if( cloned->subCallback != NULL) {#if DEBUG_TMI printf("debugCB_fromU:%p calling subCB %p/n", ctx, cloned->subCallback);#endif /* call subCB if present */ cloned->subCallback(cloned->subContext, fromUArgs, codeUnits, length, codePoint, reason, err); } else { printf("debugCB_fromU:%p, NOT calling subCB, it's NULL/n", ctx); } /* set back callback */ ucnv_setFromUCallBack(fromUArgs->converter, saveCallback, /* Us */ cloned, /* new context */ &cloned->subCallback, /* IMPORTANT! Accept any change in CB or context */ &cloned->subContext, &subErr); if(U_FAILURE(subErr)) { *err = subErr; } } /* process other reasons here */ /* always call subcb if present */ if(ctx->subCallback != NULL && reason != UCNV_CLONE) { ctx->subCallback(ctx->subContext, fromUArgs, codeUnits, length, codePoint, reason, err); } if(reason == UCNV_CLOSE) {#if DEBUG_TMI printf("debugCB_fromU: Context %p:%d closing/n", ctx, ctx->serial);#endif free(ctx); }#if DEBUG_TMI printf("debugCB_fromU: leaving cnv %p, ctx %p: err %s/n", fromUArgs->converter, ctx, u_errorName(*err));#endif}
开发者ID:winlibs,项目名称:icu4c,代码行数:95,
示例19: TestMessageCatalogvoid TestMessageCatalog(void) { UErrorCode ec = U_ZERO_ERROR; u_nl_catd catd; const char* DATA[] = { /* set_num, msg_num, expected string result, expected error code */ "1", "4", "Good morning.", "U_ZERO_ERROR", "1", "5", "Good afternoon.", "U_ZERO_ERROR", "1", "6", "FAIL", "U_MISSING_RESOURCE_ERROR", "1", "7", "Good evening.", "U_ZERO_ERROR", "1", "8", "Good night.", "U_ZERO_ERROR", "1", "9", "FAIL", "U_MISSING_RESOURCE_ERROR", "3", "1", "FAIL", "U_MISSING_RESOURCE_ERROR", "4", "14", "Please ", "U_ZERO_ERROR", "4", "15", "FAIL", "U_MISSING_RESOURCE_ERROR", "4", "19", "Thank you.", "U_ZERO_ERROR", "4", "20", "Sincerely,", "U_ZERO_ERROR", NULL }; const UChar FAIL[] = {0x46, 0x41, 0x49, 0x4C, 0x00}; /* "FAIL" */ int32_t i; const char *path = loadTestData(&ec); if (U_FAILURE(ec)) { log_data_err("FAIL: loadTestData => %s/n", u_errorName(ec)); return; } catd = u_catopen(path, "mc", &ec); if (U_FAILURE(ec)) { log_data_err("FAIL: u_catopen => %s/n", u_errorName(ec)); return; } for (i=0; DATA[i]!=NULL; i+=4) { int32_t set_num = T_CString_stringToInteger(DATA[i], 10); int32_t msg_num = T_CString_stringToInteger(DATA[i+1], 10); UChar exp[128]; int32_t len = -1; const char* err; char str[128]; const UChar* ustr; u_uastrcpy(exp, DATA[i+2]); ec = U_ZERO_ERROR; ustr = u_catgets(catd, set_num, msg_num, FAIL, &len, &ec); u_austrcpy(str, ustr); err = u_errorName(ec); log_verbose("u_catgets(%d, %d) => /"%s/", len=%d, %s/n", set_num, msg_num, str, len, err); if (u_strcmp(ustr, exp) != 0) { log_err("FAIL: u_catgets => /"%s/", exp. /"%s/"/n", str, DATA[i+2]); } if (len != (int32_t) uprv_strlen(DATA[i+2])) { log_err("FAIL: u_catgets => len=%d, exp. %d/n", len, uprv_strlen(DATA[i+2])); } if (uprv_strcmp(err, DATA[i+3]) != 0) { log_err("FAIL: u_catgets => %s, exp. %s/n", err, DATA[i+3]); } } u_catclose(catd);}
开发者ID:LittoCats,项目名称:OT_4010D,代码行数:71,
示例20: main//----------------------------------------------------------------------------//// main for genbrk////----------------------------------------------------------------------------int main(int argc, char **argv) { UErrorCode status = U_ZERO_ERROR; const char *ruleFileName; const char *outFileName; const char *outDir = NULL; const char *copyright = NULL; // // Pick up and check the command line arguments, // using the standard ICU tool utils option handling. // U_MAIN_INIT_ARGS(argc, argv); progName = argv[0]; argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); if(argc<0) { // Unrecognized option fprintf(stderr, "error in command line argument /"%s/"/n", argv[-argc]); usageAndDie(U_ILLEGAL_ARGUMENT_ERROR); } if(options[0].doesOccur || options[1].doesOccur) { // -? or -h for help. usageAndDie(0); } if (!(options[3].doesOccur && options[4].doesOccur)) { fprintf(stderr, "rule file and output file must both be specified./n"); usageAndDie(U_ILLEGAL_ARGUMENT_ERROR); } ruleFileName = options[3].value; outFileName = options[4].value; if (options[5].doesOccur) { u_setDataDirectory(options[5].value); } /* Initialize ICU */ u_init(&status); if (U_FAILURE(status)) { fprintf(stderr, "%s: can not initialize ICU. status = %s/n", argv[0], u_errorName(status)); exit(1); } status = U_ZERO_ERROR; /* Combine the directory with the file name */ if(options[6].doesOccur) { outDir = options[6].value; } if (options[7].doesOccur) { copyright = U_COPYRIGHT_STRING; }#if UCONFIG_NO_BREAK_ITERATION UNewDataMemory *pData; char msg[1024]; /* write message with just the name */ sprintf(msg, "genbrk writes dummy %s because of UCONFIG_NO_BREAK_ITERATION, see uconfig.h", outFileName); fprintf(stderr, "%s/n", msg); /* write the dummy data file */ pData = udata_create(outDir, NULL, outFileName, &dummyDataInfo, NULL, &status); udata_writeBlock(pData, msg, strlen(msg)); udata_finish(pData, &status); return (int)status;#else // // Read in the rule source file // long result; long ruleFileSize; FILE *file; char *ruleBufferC; file = fopen(ruleFileName, "rb"); if( file == 0 ) { fprintf(stderr, "Could not open file /"%s/"/n", ruleFileName); exit(-1); } fseek(file, 0, SEEK_END); ruleFileSize = ftell(file); fseek(file, 0, SEEK_SET); ruleBufferC = new char[ruleFileSize+10]; result = (long)fread(ruleBufferC, 1, ruleFileSize, file); if (result != ruleFileSize) { fprintf(stderr, "Error reading file /"%s/"/n", ruleFileName); exit (-1); } ruleBufferC[ruleFileSize]=0; fclose(file);//.........这里部分代码省略.........
开发者ID:mason105,项目名称:red5cpp,代码行数:101,
示例21: throwRuntimeExceptionstatic void throwRuntimeException(JNIEnv* env, UErrorCode status) { jniThrowRuntimeException(env, u_errorName(status));}
开发者ID:Ar3kkusu,项目名称:android_libcore,代码行数:3,
示例22: _processCollatorOptionstatic const char* U_CALLCONV_processCollatorOption(CollatorSpec *spec, uint32_t option, const char* string, UErrorCode *status){ spec->options[option] = ucol_sit_letterToAttributeValue(*string, status); if((*(++string) != '_' && *string) || U_FAILURE(*status)) {#ifdef UCOL_TRACE_SIT fprintf(stderr, "%s:%d: unknown collator option at '%s': %s/n", __FILE__, __LINE__, string, u_errorName(*status));#endif *status = U_ILLEGAL_ARGUMENT_ERROR; } return string;}
开发者ID:MIPS,项目名称:external-icu,代码行数:13,
示例23: yaz_xml_get_propstruct icu_chain *icu_chain_xml_config(const xmlNode *xml_node, int sort, UErrorCode *status){ xmlNode *node = 0; int no_errors = 0; struct icu_chain *chain = 0; NMEM nmem = 0; *status = U_ZERO_ERROR; if (xml_node && xml_node->type == XML_ELEMENT_NODE) { const char *xml_locale = yaz_xml_get_prop((xmlNode *) xml_node, "locale"); if (xml_locale) chain = icu_chain_create((const char *) xml_locale, sort, status); } if (!chain) return 0; nmem = nmem_create(); for (node = xml_node->children; node; node = node->next) { char *rule = 0; struct icu_chain_step *step = 0; const char *attr_str; nmem_reset(nmem); if (node->type != XML_ELEMENT_NODE) continue; attr_str = yaz_xml_get_prop(node, "rule%s", &rule); if (attr_str) { yaz_log(YLOG_WARN, "Unsupported attribute '%s' for " "element '%s'", attr_str, node->name); no_errors++; } if (!rule && node->children) rule = nmem_text_node_cdata(node->children, nmem); if (!rule && strcmp((const char *) node->name, "display")) { yaz_log(YLOG_WARN, "Missing attribute 'rule' for element %s", (const char *) node->name); no_errors++; continue; } if (!strcmp((const char *) node->name, "casemap")) step = icu_chain_insert_step(chain, ICU_chain_step_type_casemap, rule, status); else if (!strcmp((const char *) node->name, "transform")) step = icu_chain_insert_step(chain, ICU_chain_step_type_transform, rule, status); else if (!strcmp((const char *) node->name, "transliterate")) step = icu_chain_insert_step(chain, ICU_chain_step_type_transliterate, rule, status); else if (!strcmp((const char *) node->name, "tokenize")) step = icu_chain_insert_step(chain, ICU_chain_step_type_tokenize, rule, status); else if (!strcmp((const char *) node->name, "display")) step = icu_chain_insert_step(chain, ICU_chain_step_type_display, rule, status); else if (!strcmp((const char *) node->name, "stemming")) step = icu_chain_insert_step(chain, YAZ_chain_step_type_stemming, rule, status); else if (!strcmp((const char *) node->name, "join")) step = icu_chain_insert_step(chain, ICU_chain_step_type_join, rule, status); else if (!strcmp((const char *) node->name, "normalize")) { yaz_log(YLOG_WARN, "Element %s is deprecated. " "Use transform instead", node->name); step = icu_chain_insert_step(chain, ICU_chain_step_type_transform, rule, status); } else if (!strcmp((const char *) node->name, "index") || !strcmp((const char *) node->name, "sortkey")) { yaz_log(YLOG_WARN, "Element %s is no longer needed. " "Remove it from the configuration", node->name); } else { yaz_log(YLOG_WARN, "Unknown element %s", node->name); no_errors++; continue; } if (!step) { yaz_log(YLOG_WARN, "Step not created for %s", node->name); no_errors++; } if (step && U_FAILURE(*status)) { yaz_log(YLOG_WARN, "ICU Error %d %s for element %s, rule %s",//.........这里部分代码省略.........
开发者ID:dcrossleyau,项目名称:yaz,代码行数:101,
示例24: verifyEnumerationstatic void verifyEnumeration(int line, UEnumeration *u, const char * const * compareToChar, const UChar * const * compareToUChar, int32_t expect_count) { UErrorCode status = U_ZERO_ERROR; int32_t got_count,i,len; const char *c; UChar buf[1024]; log_verbose("%s:%d: verifying enumeration../n", __FILE__, line); uenum_reset(u, &status); if(U_FAILURE(status)) { log_err("%s:%d: FAIL: could not reset char strings enumeration: %s/n", __FILE__, line, u_errorName(status)); return; } got_count = uenum_count(u, &status); if(U_FAILURE(status)) { log_err("%s:%d: FAIL: could not count char strings enumeration: %s/n", __FILE__, line, u_errorName(status)); return; } if(got_count!=expect_count) { log_err("%s:%d: FAIL: expect count %d got %d/n", __FILE__, line, expect_count, got_count); } else { log_verbose("%s:%d: OK: got count %d/n", __FILE__, line, got_count); } if(compareToChar!=NULL) { /* else, not invariant */ for(i=0;i<got_count;i++) { c = uenum_next(u,&len, &status); if(U_FAILURE(status)) { log_err("%s:%d: FAIL: could not iterate to next after %d: %s/n", __FILE__, line, i, u_errorName(status)); return; } if(c==NULL) { log_err("%s:%d: FAIL: got NULL for next after %d: %s/n", __FILE__, line, i, u_errorName(status)); return; } if(strcmp(c,compareToChar[i])) { log_err("%s:%d: FAIL: string #%d expected '%s' got '%s'/n", __FILE__, line, i, compareToChar[i], c); } else { log_verbose("%s:%d: OK: string #%d got '%s'/n", __FILE__, line, i, c); } if(len!=strlen(compareToChar[i])) { log_err("%s:%d: FAIL: string #%d expected len %d got %d/n", __FILE__, line, i, strlen(compareToChar[i]), len); } else { log_verbose("%s:%d: OK: string #%d got len %d/n", __FILE__, line, i, len); } } } /* now try U */ uenum_reset(u, &status); if(U_FAILURE(status)) { log_err("%s:%d: FAIL: could not reset again char strings enumeration: %s/n", __FILE__, line, u_errorName(status)); return; } for(i=0;i<got_count;i++) { const UChar *ustr = uenum_unext(u,&len, &status); if(U_FAILURE(status)) { log_err("%s:%d: FAIL: could not iterate to unext after %d: %s/n", __FILE__, line, i, u_errorName(status)); return; } if(ustr==NULL) { log_err("%s:%d: FAIL: got NULL for unext after %d: %s/n", __FILE__, line, i, u_errorName(status)); return; } if(compareToChar!=NULL) { u_charsToUChars(compareToChar[i], buf, strlen(compareToChar[i])+1); if(u_strncmp(ustr,buf,len)) { int j; log_err("%s:%d: FAIL: ustring #%d expected '%s' got '%s'/n", __FILE__, line, i, compareToChar[i], austrdup(ustr)); for(j=0;ustr[j]&&buf[j];j++) { log_verbose(" @ %d/t<U+%04X> vs <U+%04X>/n", j, ustr[j],buf[j]); } } else { log_verbose("%s:%d: OK: ustring #%d got '%s'/n", __FILE__, line, i, compareToChar[i]); } if(len!=strlen(compareToChar[i])) { log_err("%s:%d: FAIL: ustring #%d expected len %d got %d/n", __FILE__, line, i, strlen(compareToChar[i]), len); } else { log_verbose("%s:%d: OK: ustring #%d got len %d/n", __FILE__, line, i, len); } } if(compareToUChar!=NULL) { if(u_strcmp(ustr,compareToUChar[i])) { int j; log_err("%s:%d: FAIL: ustring #%d expected '%s' got '%s'/n", __FILE__, line, i, austrdup(compareToUChar[i]), austrdup(ustr)); for(j=0;ustr[j]&&compareToUChar[j];j++) { log_verbose(" @ %d/t<U+%04X> vs <U+%04X>/n", j, ustr[j],compareToUChar[j]); } } else { log_verbose("%s:%d: OK: ustring #%d got '%s'/n", __FILE__, line, i, austrdup(compareToUChar[i])); } if(len!=u_strlen(compareToUChar[i])) {//.........这里部分代码省略.........
开发者ID:00zhengfu00,项目名称:third_party,代码行数:101,
示例25: errlnvoid CollationThaiTest::TestDictionary(void) { if (coll == 0) { errln("Error: could not construct Thai collator"); return; } UErrorCode ec = U_ZERO_ERROR; TextFile riwords("riwords.txt", "UTF8", ec); if (U_FAILURE(ec)) { logln("Can't open riwords.txt: %s; skipping test", u_errorName(ec)); return; } // // Loop through each word in the dictionary and compare it to the previous // word. They should be in sorted order. // UnicodeString lastWord, word; int32_t failed = 0; int32_t wordCount = 0; while (riwords.readLineSkippingComments(word, ec, FALSE) && U_SUCCESS(ec)) { // Show the first 8 words being compared, so we can see what's happening ++wordCount; if (wordCount <= 8) { UnicodeString str; logln((UnicodeString)"Word " + wordCount + ": " + IntlTest::prettify(word, str)); } if (lastWord.length() > 0) { // line enabled for j2720 doTest(coll, lastWord, word, Collator::LESS); int32_t result = coll->compare(lastWord, word); if (result >= 0) { failed++; if (MAX_FAILURES_TO_SHOW < 0 || failed <= MAX_FAILURES_TO_SHOW) { UnicodeString str; UnicodeString msg = UnicodeString("--------------------------------------------/n") + riwords.getLineNumber() + " compare(" + IntlTest::prettify(lastWord, str); msg += UnicodeString(", ") + IntlTest::prettify(word, str) + ") returned " + result + ", expected -1/n"; UErrorCode status = U_ZERO_ERROR; CollationKey k1, k2; coll->getCollationKey(lastWord, k1, status); coll->getCollationKey(word, k2, status); if (U_FAILURE(status)) { errln((UnicodeString)"Fail: getCollationKey returned " + u_errorName(status)); return; } msg.append("key1: ").append(prettify(k1, str)).append("/n"); msg.append("key2: ").append(prettify(k2, str)); errln(msg); } } } lastWord = word; } assertSuccess("readLine", ec); if (failed != 0) { if (failed > MAX_FAILURES_TO_SHOW) { errln((UnicodeString)"Too many failures; only the first " + MAX_FAILURES_TO_SHOW + " failures were shown"); } errln((UnicodeString)"Summary: " + failed + " of " + (riwords.getLineNumber() - 1) + " comparisons failed"); } logln((UnicodeString)"Words checked: " + wordCount);}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:76,
示例26: locale//.........这里部分代码省略......... const char *name; Locale locale(localeID); result=input; switch(whichCase) { case TEST_LOWER: name="toLower"; result.toLower(locale); break; case TEST_UPPER: name="toUpper"; result.toUpper(locale); break;#if !UCONFIG_NO_BREAK_ITERATION case TEST_TITLE: name="toTitle"; result.toTitle((BreakIterator *)iter, locale, options); break;#endif case TEST_FOLD: name="foldCase"; result.foldCase(options); break; default: name=""; break; // won't happen } if(result!=output) { dataerrln("error: UnicodeString.%s() got a wrong result for a test case from casing.res", name); }#if !UCONFIG_NO_BREAK_ITERATION if(whichCase==TEST_TITLE && options==0) { result=input; result.toTitle((BreakIterator *)iter, locale); if(result!=output) { dataerrln("error: UnicodeString.toTitle(options=0) got a wrong result for a test case from casing.res"); } }#endif // UTF-8 char utf8In[100], utf8Out[100]; int32_t utf8InLength, utf8OutLength, resultLength; UChar *buffer; IcuTestErrorCode errorCode(*this, "TestCasingImpl"); LocalUCaseMapPointer csm(ucasemap_open(localeID, options, errorCode));#if !UCONFIG_NO_BREAK_ITERATION if(iter!=NULL) { // Clone the break iterator so that the UCaseMap can safely adopt it. UBreakIterator *clone=ubrk_safeClone((UBreakIterator *)iter, NULL, NULL, errorCode); ucasemap_setBreakIterator(csm.getAlias(), clone, errorCode); }#endif u_strToUTF8(utf8In, (int32_t)sizeof(utf8In), &utf8InLength, input.getBuffer(), input.length(), errorCode); switch(whichCase) { case TEST_LOWER: name="ucasemap_utf8ToLower"; utf8OutLength=ucasemap_utf8ToLower(csm.getAlias(), utf8Out, (int32_t)sizeof(utf8Out), utf8In, utf8InLength, errorCode); break; case TEST_UPPER: name="ucasemap_utf8ToUpper"; utf8OutLength=ucasemap_utf8ToUpper(csm.getAlias(), utf8Out, (int32_t)sizeof(utf8Out), utf8In, utf8InLength, errorCode); break;#if !UCONFIG_NO_BREAK_ITERATION case TEST_TITLE: name="ucasemap_utf8ToTitle"; utf8OutLength=ucasemap_utf8ToTitle(csm.getAlias(), utf8Out, (int32_t)sizeof(utf8Out), utf8In, utf8InLength, errorCode); break;#endif case TEST_FOLD: name="ucasemap_utf8FoldCase"; utf8OutLength=ucasemap_utf8FoldCase(csm.getAlias(), utf8Out, (int32_t)sizeof(utf8Out), utf8In, utf8InLength, errorCode); break; default: name=""; utf8OutLength=0; break; // won't happen } buffer=result.getBuffer(utf8OutLength); u_strFromUTF8(buffer, result.getCapacity(), &resultLength, utf8Out, utf8OutLength, errorCode); result.releaseBuffer(errorCode.isSuccess() ? resultLength : 0); if(errorCode.isFailure()) { errcheckln(errorCode, "error: %s() got an error for a test case from casing.res - %s", name, u_errorName(errorCode)); errorCode.reset(); } else if(result!=output) { errln("error: %s() got a wrong result for a test case from casing.res", name); errln("expected /"" + output + "/" got /"" + result + "/"" ); }}
开发者ID:Acorld,项目名称:WinObjC-Heading,代码行数:101,
注:本文中的u_errorName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ u_fclose函数代码示例 C++ u_entity函数代码示例 |