当前位置: 首页>>代码示例>>C++>>正文


C++ Transliterator::createInverse方法代码示例

本文整理汇总了C++中Transliterator::createInverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Transliterator::createInverse方法的具体用法?C++ Transliterator::createInverse怎么用?C++ Transliterator::createInverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transliterator的用法示例。


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

示例1: dataerrln

void
JamoTest::TestJamo() {
    UParseError parseError;
    UErrorCode status = U_ZERO_ERROR;
    Transliterator* latinJamo = Transliterator::createInstance("Latin-Jamo", UTRANS_FORWARD, parseError, status);

    if (latinJamo == 0 || U_FAILURE(status)) {
        dataerrln("FAIL: createInstance() returned 0 - %s", u_errorName(status));
        return;
    }

    Transliterator* jamoLatin = latinJamo->createInverse(status);

    if (jamoLatin == 0) {
        delete latinJamo;
        errln("FAIL: createInverse() returned 0");
        return;
    }

    static const char* CASE[] = {
        // Column 1 is the latin text L1 to be fed to Latin-Jamo
        // to yield output J.
        
        // Column 2 is expected value of J.  J is fed to
        // Jamo-Latin to yield output L2.
        
        // Column 3 is expected value of L2.  If the expected
        // value of L2 is L1, then L2 is NULL.

                // add tests for the update to fix problems where it didn't follow the standard
                // see also http://www.unicode.org/cldr/data/charts/transforms/Latin-Hangul.html
                "gach", "(Gi)(A)(Cf)", NULL,
                "geumhui", "(Gi)(EU)(Mf)(Hi)(YI)", NULL,
                "choe", "(Ci)(OE)", NULL,
                "wo", "(IEUNG)(WEO)", NULL,
                "Wonpil", "(IEUNG)(WEO)(Nf)(Pi)(I)(L)", "wonpil",
                "GIPPEUM", "(Gi)(I)(BB)(EU)(Mf)", "gippeum",
                "EUTTEUM", "(IEUNG)(EU)(DD)(EU)(Mf)", "eutteum",
                "KKOTNAE", "(GGi)(O)(Tf)(Ni)(AE)", "kkotnae",
                "gaga", "(Gi)(A)(Gi)(A)", NULL,
                "gag-a", "(Gi)(A)(Gf)(IEUNG)(A)", NULL,
                "gak-ka", "(Gi)(A)(Kf)(Ki)(A)", NULL,
                "gakka", "(Gi)(A)(GGi)(A)", NULL,
                "gakk-a", "(Gi)(A)(GGf)(IEUNG)(A)", NULL,
                "gakkka", "(Gi)(A)(GGf)(Ki)(A)", NULL,
                "gak-kka", "(Gi)(A)(Kf)(GGi)(A)", NULL,

        "bab", "(Bi)(A)(Bf)", NULL,
        "babb", "(Bi)(A)(Bf)(Bi)(EU)", "babbeu",
        "babbba", "(Bi)(A)(Bf)(Bi)(EU)(Bi)(A)", "babbeuba",
        "bagg", "(Bi)(A)(Gf)(Gi)(EU)", "baggeu",
        "baggga", "(Bi)(A)(Gf)(Gi)(EU)(Gi)(A)", "baggeuga",
        //"bag" SEP "gga", "(Bi)(A)(Gf)" SEP "(Gi)(EU)(Gi)(A)", "bag" SEP "geuga",
        "kabsa", "(Ki)(A)(Bf)(Si)(A)", NULL,
        "kabska", "(Ki)(A)(BS)(Ki)(A)", NULL,
        "gabsbka", "(Gi)(A)(BS)(Bi)(EU)(Ki)(A)", "gabsbeuka", // not (Kf)
        "gga", "(Gi)(EU)(Gi)(A)", "geuga",
        "bsa", "(Bi)(EU)(Si)(A)", "beusa",
        "agg", "(IEUNG)(A)(Gf)(Gi)(EU)", "aggeu",
        "agga", "(IEUNG)(A)(Gf)(Gi)(A)", NULL,
        "la", "(R)(A)", NULL,
        "bs", "(Bi)(EU)(Sf)", "beus",
        "kalgga", "(Ki)(A)(L)(Gi)(EU)(Gi)(A)", "kalgeuga",
        
        // 'r' in a final position is treated like 'l'
        "karka", "(Ki)(A)(L)(Ki)(A)", "kalka",
    };

    enum { CASE_length = sizeof(CASE) / sizeof(CASE[0]) };
    
    int32_t i;
    for (i=0; i<CASE_length; i+=3) {
        UnicodeString jamo = nameToJamo(CASE[i+1]);
        if (CASE[i+2] == NULL) {
            expect(*latinJamo, CASE[i], jamo, *jamoLatin);
        } else {
            // Handle case where round-trip is expected to fail
            expect(*latinJamo, CASE[i], jamo);
            expect(*jamoLatin, jamo, CASE[i+2]);
        }
    }

    delete latinJamo;
    delete jamoLatin;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:85,代码来源:jamotest.cpp

示例2: rt


//.........这里部分代码省略.........
      "\\ube44\\uc601\\ub9ac", "\\uc870\\uc9c1\\uc73c\\ub85c\\uc11c", "\\ud604\\ub300",
      "\\uc18c\\ud504\\ud2b8\\uc6e8\\uc5b4", "\\uc81c\\ud488\\uacfc",
      "\\ud45c\\uc900\\uc5d0\\uc11c", "\\ud14d\\uc2a4\\ud2b8\\uc758", "\\ud45c\\ud604\\uc744",
      "\\uc9c0\\uc815\\ud558\\ub294", "\\uc720\\ub2c8\\ucf54\\ub4dc", "\\ud45c\\uc900\\uc758",
      "\\uc0ac\\uc6a9\\uc744", "\\uac1c\\ubc1c\\ud558\\uace0", "\\ud655\\uc7a5\\ud558\\uba70",
      "\\uc7a5\\ub824\\ud558\\uae30", "\\uc704\\ud574",
      "\\uc138\\uc6cc\\uc84c\\uc2b5\\ub2c8\\ub2e4.", "\\ucf58\\uc18c\\uc2dc\\uc5c4",
      "\\uba64\\ubc84\\uc27d\\uc740", "\\ucef4\\ud4e8\\ud130\\uc640", "\\uc815\\ubcf4",
      "\\ucc98\\ub9ac", "\\uc0b0\\uc5c5\\uc5d0", "\\uc885\\uc0ac\\ud558\\uace0", "\\uc788\\ub294",
      "\\uad11\\ubc94\\uc704\\ud55c", "\\ud68c\\uc0ac", "\\ubc0f", "\\uc870\\uc9c1\\uc758",
      "\\ubc94\\uc704\\ub97c",
      "\\ub098\\ud0c0\\ub0c5\\ub2c8\\ub2e4.", "\\ucf58\\uc18c\\uc2dc\\uc5c4\\uc758",
      "\\uc7ac\\uc815\\uc740", "\\uc804\\uc801\\uc73c\\ub85c", "\\ud68c\\ube44\\uc5d0",
      "\\uc758\\ud574", "\\ucda9\\ub2f9\\ub429\\ub2c8\\ub2e4.", "\\uc720\\ub2c8\\ucf54\\ub4dc",
      "\\ucee8\\uc18c\\uc2dc\\uc5c4\\uc5d0\\uc11c\\uc758", "\\uba64\\ubc84\\uc27d\\uc740",
      "\\uc804", "\\uc138\\uacc4", "\\uc5b4\\ub290", "\\uacf3\\uc5d0\\uc11c\\ub098",
      "\\uc720\\ub2c8\\ucf54\\ub4dc", "\\ud45c\\uc900\\uc744", "\\uc9c0\\uc6d0\\ud558\\uace0",
      "\\uadf8", "\\ud655\\uc7a5\\uacfc", "\\uad6c\\ud604\\uc744",
      "\\uc9c0\\uc6d0\\ud558\\uace0\\uc790\\ud558\\ub294", "\\uc870\\uc9c1\\uacfc",
      "\\uac1c\\uc778\\uc5d0\\uac8c", "\\uac1c\\ubc29\\ub418\\uc5b4",
      "\\uc788\\uc2b5\\ub2c8\\ub2e4.",

      "\\ub354", "\\uc790\\uc138\\ud55c", "\\ub0b4\\uc6a9\\uc740", "\\uc6a9\\uc5b4\\uc9d1,",
      "\\uc608\\uc81c", "\\uc720\\ub2c8\\ucf54\\ub4dc", "\\uc0ac\\uc6a9", "\\uac00\\ub2a5",
      "\\uc81c\\ud488,", "\\uae30\\uc220", "\\uc815\\ubcf4", "\\ubc0f", "\\uae30\\ud0c0",
      "\\uc720\\uc6a9\\ud55c", "\\uc815\\ubcf4\\ub97c",
      "\\ucc38\\uc870\\ud558\\uc2ed\\uc2dc\\uc624."
    };

    enum { WHAT_IS_UNICODE_length = sizeof(WHAT_IS_UNICODE) / sizeof(WHAT_IS_UNICODE[0]) };

    UParseError parseError;
    UErrorCode status = U_ZERO_ERROR;
    Transliterator* latinJamo = Transliterator::createInstance("Latin-Jamo", UTRANS_FORWARD, parseError, status);
    Transliterator* jamoHangul = Transliterator::createInstance("NFC(NFD)", UTRANS_FORWARD, parseError, status);
    if (latinJamo == 0 || jamoHangul == 0 || U_FAILURE(status)) {
        delete latinJamo;
        delete jamoHangul;
        dataerrln("FAIL: createInstance returned NULL - %s", u_errorName(status));
        return;
    }
    Transliterator* jamoLatin = latinJamo->createInverse(status);
    Transliterator* hangulJamo = jamoHangul->createInverse(status);
    if (jamoLatin == 0 || hangulJamo == 0) {
        errln("FAIL: createInverse returned NULL");
        delete latinJamo;
        delete jamoLatin;
        delete jamoHangul;
        delete hangulJamo;
        return;
    }

    Transliterator* tarray[4] =
        { hangulJamo, jamoLatin, latinJamo, jamoHangul };
    CompoundTransliterator rt(tarray, 4);
    
    UnicodeString buf;
    int32_t total = 0;
    int32_t errors = 0;
    int32_t i;
    for (i=0; i < WHAT_IS_UNICODE_length; ++i) {
        ++total;
        UnicodeString hangul = UnicodeString(WHAT_IS_UNICODE[i], -1, US_INV);
        hangul = hangul.unescape(); // Parse backslash-u escapes
        UnicodeString hangulX = hangul;
        rt.transliterate(hangulX);
        if (hangul != hangulX) {
            ++errors;
            UnicodeString jamo = hangul; hangulJamo->transliterate(jamo);
            UnicodeString latin = jamo; jamoLatin->transliterate(latin);
            UnicodeString jamo2 = latin; latinJamo->transliterate(jamo2);
            UnicodeString hangul2 = jamo2; jamoHangul->transliterate(hangul2);
            
            buf.remove(0);
            buf.append("FAIL: ");
            if (hangul2 != hangulX) {
                buf.append((UnicodeString)"(Weird: " + hangulX + " != " + hangul2 + ")");
            }
            // The Hangul-Jamo conversion is not usually the
            // bug here, so we hide it from display.
            // Uncomment lines to see the Hangul.
            buf.append(//hangul + " => " +
                       jamoToName(jamo) + " => " +
                       latin + " => " + jamoToName(jamo2)
                       //+ " => " + hangul2
                       );
            errln(prettify(buf));
        }
    }
    if (errors != 0) {
        errln((UnicodeString)"Test word failures: " + errors + " out of " + total);
    } else {
        logln((UnicodeString)"All " + total + " test words passed");
    }

    delete latinJamo;
    delete jamoLatin;
    delete jamoHangul;
    delete hangulJamo;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,代码来源:jamotest.cpp


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