本文整理汇总了C++中Transliterator类的典型用法代码示例。如果您正苦于以下问题:C++ Transliterator类的具体用法?C++ Transliterator怎么用?C++ Transliterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transliterator类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
// ///////////// M A I N ///////////////
int main() {
// UTF8 string
UnicodeString lString ("À côté de chez vous");
UnicodeString lNormalisedString (lString);
// Create a Normalizer
UErrorCode status = U_ZERO_ERROR;
const char* lNormaliserID = "NFD; [:M:] Remove; NFC;";
Transliterator* lNormaliser =
Transliterator::createInstance (lNormaliserID, UTRANS_FORWARD, status);
if (lNormaliser == NULL || U_FAILURE (status)) {
std::cerr << "ERROR: Transliterator::createInstance() failed for "
<< lNormaliserID << std::endl;
return 0;
}
assert (lNormaliser != NULL);
// Register the Transliterator
Transliterator::registerInstance (lNormaliser);
// Normalise the string
lNormaliser->transliterate (lNormalisedString);
std::cout << "Original version (UTF8): '"
<< uprintf (lString)
<< "'; normalized version without accents: '"
<< uprintf (lNormalisedString) << "'" << std::endl;
return 0;
}
开发者ID:denisarnaud,项目名称:playground,代码行数:33,代码来源:icutranslit_simple.cpp
示例2: createBasicInstance
Transliterator * TransliteratorIDParser::SingleID::createInstance()
{
Transliterator * t;
if (basicID.length() == 0)
{
t = createBasicInstance(ANY_NULL, &canonID);
}
else
{
t = createBasicInstance(basicID, &canonID);
}
if (t != NULL)
{
if (filter.length() != 0)
{
UErrorCode ec = U_ZERO_ERROR;
UnicodeSet * set = new UnicodeSet(filter, ec);
if (U_FAILURE(ec))
{
delete set;
}
else
{
t->adoptFilter(set);
}
}
}
return t;
}
开发者ID:Botyto,项目名称:Core,代码行数:29,代码来源:tridpars.cpp
示例3: list
Transliterator* U_EXPORT2
Transliterator::createInstance(const UnicodeString& ID,
UTransDirection dir,
UParseError& parseError,
UErrorCode& status)
{
if (U_FAILURE(status)) {
return 0;
}
UnicodeString canonID;
UVector list(status);
if (U_FAILURE(status)) {
return NULL;
}
UnicodeSet* globalFilter;
// TODO add code for parseError...currently unused, but
// later may be used by parsing code...
if (!TransliteratorIDParser::parseCompoundID(ID, dir, canonID, list, globalFilter)) {
status = U_INVALID_ID;
return NULL;
}
TransliteratorIDParser::instantiateList(list, status);
if (U_FAILURE(status)) {
return NULL;
}
U_ASSERT(list.size() > 0);
Transliterator* t = NULL;
if (list.size() > 1 || canonID.indexOf(ID_DELIM) >= 0) {
// [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only
// has one child transliterator. This is so that toRules() will return the right thing
// (without any inactive ID), but our main ID still comes out correct. That is, if we
// instantiate "(Lower);Latin-Greek;", we want the rules to come out as "::Latin-Greek;"
// even though the ID is "(Lower);Latin-Greek;".
t = new CompoundTransliterator(list, parseError, status);
}
else {
t = (Transliterator*)list.elementAt(0);
}
// Check null pointer
if (t != NULL) {
t->setID(canonID);
if (globalFilter != NULL) {
t->adoptFilter(globalFilter);
}
}
else if (U_SUCCESS(status)) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return t;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:55,代码来源:translit.cpp
示例4: ucnv_setDefaultName
std::string kiwix::removeAccents(const std::string &text) {
ucnv_setDefaultName("UTF-8");
UErrorCode status = U_ZERO_ERROR;
Transliterator *removeAccentsTrans = Transliterator::createInstance("Lower; NFD; [:M:] remove; NFC", UTRANS_FORWARD, status);
UnicodeString ustring = UnicodeString(text.c_str());
removeAccentsTrans->transliterate(ustring);
delete removeAccentsTrans;
std::string unaccentedText;
ustring.toUTF8String(unaccentedText);
return unaccentedText;
}
开发者ID:kiranmathewkoshy,项目名称:kiwix_mirror,代码行数:11,代码来源:stringTools.cpp
示例5: Transliterator_transliterate
static jstring Transliterator_transliterate(JNIEnv* env, jclass, jlong peer, jstring javaString) {
Transliterator* t = fromPeer(peer);
ScopedJavaUnicodeString string(env, javaString);
if (!string.valid()) {
return NULL;
}
UnicodeString& s(string.unicodeString());
t->transliterate(s);
return env->NewString(s.getBuffer(), s.length());
}
开发者ID:dicej,项目名称:android-libcore64,代码行数:11,代码来源:libcore_icu_Transliterator.cpp
示例6: UnicodeString
void TransliteratorAPITest::TestTransliterate1(){
UnicodeString Data[]={
//ID, input string, transliterated string
"Any-Hex", "hello", UnicodeString("\\u0068\\u0065\\u006C\\u006C\\u006F", "") ,
"Hex-Any", UnicodeString("\\u0068\\u0065\\u006C\\u006C\\u006F", ""), "hello" ,
"Latin-Devanagari",CharsToUnicodeString("bha\\u0304rata"), CharsToUnicodeString("\\u092D\\u093E\\u0930\\u0924") ,
"Latin-Devanagari",UnicodeString("kra ksha khra gra cra dya dhya",""), CharsToUnicodeString("\\u0915\\u094D\\u0930 \\u0915\\u094D\\u0936 \\u0916\\u094D\\u0930 \\u0917\\u094D\\u0930 \\u091a\\u094D\\u0930 \\u0926\\u094D\\u092F \\u0927\\u094D\\u092F") ,
"Devanagari-Latin", CharsToUnicodeString("\\u092D\\u093E\\u0930\\u0924"), CharsToUnicodeString("bh\\u0101rata"),
// "Contracted-Expanded", CharsToUnicodeString("\\u00C0\\u00C1\\u0042"), CharsToUnicodeString("\\u0041\\u0300\\u0041\\u0301\\u0042") ,
// "Expanded-Contracted", CharsToUnicodeString("\\u0041\\u0300\\u0041\\u0301\\u0042"), CharsToUnicodeString("\\u00C0\\u00C1\\u0042") ,
//"Latin-Arabic", "aap", CharsToUnicodeString("\\u0627\\u06A4") ,
//"Arabic-Latin", CharsToUnicodeString("\\u0627\\u06A4"), "aap"
};
UnicodeString gotResult;
UnicodeString temp;
UnicodeString message;
Transliterator* t;
logln("Testing transliterate");
UErrorCode status = U_ZERO_ERROR;
UParseError parseError;
for(uint32_t i=0;i<sizeof(Data)/sizeof(Data[0]); i=i+3){
t=Transliterator::createInstance(Data[i+0], UTRANS_FORWARD, parseError, status);
if(t==0){
dataerrln("FAIL: construction: " + Data[i+0] + " Error: " + u_errorName(status));
dataerrln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
status = U_ZERO_ERROR;
continue;
}
gotResult = Data[i+1];
t->transliterate(gotResult);
message=t->getID() + "->transliterate(UnicodeString, UnicodeString) for\n\t Source:" + prettify(Data[i+1]);
doTest(message, gotResult, Data[i+2]);
//doubt here
temp=Data[i+1];
t->transliterate(temp);
message.remove();
message.append(t->getID());
message.append("->transliterate(Replaceable) for \n\tSource:");
message.append(Data[i][1]);
doTest(message, temp, Data[i+2]);
callEverything(t, __LINE__);
delete t;
}
}
开发者ID:LittoCats,项目名称:OT_4010D,代码行数:50,代码来源:transapi.cpp
示例7: TestReplaceable
void ReplaceableTest::check(const UnicodeString& transliteratorName,
const UnicodeString& test,
const UnicodeString& shouldProduceStyles)
{
UErrorCode status = U_ZERO_ERROR;
TestReplaceable *tr = new TestReplaceable(test, "");
UnicodeString expectedStyles = shouldProduceStyles;
UnicodeString original = tr->toString();
Transliterator* t;
if (transliteratorName.charAt(0) == 0x2A /*'*'*/) {
UnicodeString rules(transliteratorName);
rules.remove(0,1);
UParseError pe;
t = Transliterator::createFromRules("test", rules, UTRANS_FORWARD,
pe, status);
// test clone()
TestReplaceable *tr2 = (TestReplaceable *)tr->clone();
if(tr2 != NULL) {
delete tr;
tr = tr2;
}
} else {
t = Transliterator::createInstance(transliteratorName, UTRANS_FORWARD, status);
}
if (U_FAILURE(status)) {
log("FAIL: failed to create the ");
log(transliteratorName);
errln(" transliterator.");
delete tr;
return;
}
t->transliterate(*tr);
UnicodeString newStyles = tr->getStyles();
if (newStyles != expectedStyles) {
errln("FAIL Styles: " + transliteratorName + "{" + original + "} => "
+ tr->toString() + "; should be {" + expectedStyles + "}!");
} else {
log("OK: ");
log(transliteratorName);
log("(");
log(original);
log(") => ");
logln(tr->toString());
}
delete tr;
delete t;
}
开发者ID:andrewleech,项目名称:firebird,代码行数:49,代码来源:reptest.cpp
示例8: removeAccents
string removeAccents(const string& str)
{
UnicodeString source = UnicodeString::fromUTF8(str.c_str());
UErrorCode status = U_ZERO_ERROR;
Transliterator* accentsConverter = Transliterator::createInstance("NFD; [:M:] Remove; NFC", UTRANS_FORWARD, status);
accentsConverter->transliterate(source);
delete accentsConverter;
string result;
source.toUTF8String(result);
return result;
}
开发者ID:pescuma,项目名称:dummy-media-manager,代码行数:16,代码来源:utf8.cpp
示例9: it
/**
* Implements {@link Transliterator#handleTransliterate}.
*/
void AnyTransliterator::handleTransliterate(Replaceable& text, UTransPosition& pos,
UBool isIncremental) const {
int32_t allStart = pos.start;
int32_t allLimit = pos.limit;
ScriptRunIterator it(text, pos.contextStart, pos.contextLimit);
while (it.next()) {
// Ignore runs in the ante context
if (it.limit <= allStart) continue;
// Try to instantiate transliterator from it.scriptCode to
// our target or target/variant
Transliterator* t = getTransliterator(it.scriptCode);
if (t == NULL) {
// We have no transliterator. Do nothing, but keep
// pos.start up to date.
pos.start = it.limit;
continue;
}
// If the run end is before the transliteration limit, do
// a non-incremental transliteration. Otherwise do an
// incremental one.
UBool incremental = isIncremental && (it.limit >= allLimit);
pos.start = uprv_max(allStart, it.start);
pos.limit = uprv_min(allLimit, it.limit);
int32_t limit = pos.limit;
t->filteredTransliterate(text, pos, incremental);
int32_t delta = pos.limit - limit;
allLimit += delta;
it.adjustLimit(delta);
// We're done if we enter the post context
if (it.limit >= allLimit) break;
}
// Restore limit. pos.start is fine where the last transliterator
// left it, or at the end of the last run.
pos.limit = allLimit;
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:46,代码来源:anytrans.cpp
示例10: icuTransform
static QByteArray
icuTransform( const QByteArray& _id, const QByteArray& _text, const RenderingContext& c )
{
UnicodeString id = UnicodeString::fromUTF8( StringPiece( _id ));
UnicodeString text = UnicodeString::fromUTF8( StringPiece( _text ));
UErrorCode status = U_ZERO_ERROR;
Transliterator *t = Transliterator::createInstance( id, UTRANS_FORWARD, status );
if( U_FAILURE( status )) {
c.info( QString( "icu_transform: Error %1 (%2)" )
.arg( status )
.arg( u_errorName( status )));
return _text;
}
t->transliterate( text );
QByteArray result;
text.toUTF8String(result);
return result;
}
开发者ID:mdhooge,项目名称:qt-handlebars,代码行数:20,代码来源:IcuHelpers.cpp
示例11: logln
void TransliteratorAPITest::TestGetDisplayName() {
UnicodeString dispNames[]= {
//ID, displayName
//"CurlyQuotes-StraightQuotes" ,"CurlyQuotes to StraightQuotes",
"Any-Hex" ,"Any to Hex Escape",
"Halfwidth-Fullwidth" ,"Halfwidth to Fullwidth" ,
//"Latin-Arabic" ,"Latin to Arabic" ,
"Latin-Devanagari" ,"Latin to Devanagari" ,
"Greek-Latin" ,"Greek to Latin" ,
//"Arabic-Latin" ,"Arabic to Latin" ,
"Hex-Any" ,"Hex Escape to Any",
"Cyrillic-Latin" ,"Cyrillic to Latin" ,
"Latin-Greek" ,"Latin to Greek" ,
"Latin-Katakana" ,"Latin to Katakana" ,
//"Latin-Hebrew" ,"Latin to Hebrew" ,
"Katakana-Latin" ,"Katakana to Latin"
};
UnicodeString name="";
Transliterator* t;
UnicodeString message;
UErrorCode status = U_ZERO_ERROR;
UParseError parseError;
#if UCONFIG_NO_FORMATTING
logln("Skipping, UCONFIG_NO_FORMATTING is set\n");
return;
#else
for (uint32_t i=0; i<sizeof(dispNames)/sizeof(dispNames[0]); i=i+2 ) {
t = Transliterator::createInstance(dispNames[i+0], UTRANS_FORWARD, parseError, status);
if(t==0){
dataerrln("FAIL: construction: " + dispNames[i+0] + " - " + u_errorName(status));
status = U_ZERO_ERROR;
continue;
}
t->getDisplayName(t->getID(), name);
message="Display name for ID:" + t->getID();
// doTest(message, name, dispNames[i+1]); //!!! This will obviously fail for any locale other than english and its children!!!
name="";
t->getDisplayName(t->getID(), Locale::getUS(), name);
message.remove();
message.append("Display name for on english locale ID:");
message.append(t->getID());
// message="Display name for on english locale ID:" + t->getID();
doTest(message, name, dispNames[i+1]);
name="";
delete t;
}
#endif
}
开发者ID:LittoCats,项目名称:OT_4010D,代码行数:52,代码来源:transapi.cpp
示例12: callEverything
void TransliteratorAPITest::callEverything(const Transliterator *tr, int line) {
Transliterator *clonedTR = tr->clone();
CEASSERT(clonedTR != NULL);
int32_t maxcl = tr->getMaximumContextLength();
CEASSERT(clonedTR->getMaximumContextLength() == maxcl);
UnicodeString id;
UnicodeString clonedId;
id = tr->getID();
clonedId = clonedTR->getID();
CEASSERT(id == clonedId);
const UnicodeFilter *filter = tr->getFilter();
const UnicodeFilter *clonedFilter = clonedTR->getFilter();
if (filter == NULL || clonedFilter == NULL) {
// If one filter is NULL they better both be NULL.
CEASSERT(filter == clonedFilter);
} else {
CEASSERT(filter != clonedFilter);
}
UnicodeString rules;
UnicodeString clonedRules;
rules = tr->toRules(rules, FALSE);
clonedRules = clonedTR->toRules(clonedRules, FALSE);
CEASSERT(rules == clonedRules);
UnicodeSet sourceSet;
UnicodeSet clonedSourceSet;
tr->getSourceSet(sourceSet);
clonedTR->getSourceSet(clonedSourceSet);
CEASSERT(clonedSourceSet == sourceSet);
UnicodeSet targetSet;
UnicodeSet clonedTargetSet;
tr->getTargetSet(targetSet);
clonedTR->getTargetSet(clonedTargetSet);
CEASSERT(targetSet == clonedTargetSet);
UClassID classID = tr->getDynamicClassID();
CEASSERT(classID == clonedTR->getDynamicClassID());
CEASSERT(classID != 0);
delete clonedTR;
}
开发者ID:LittoCats,项目名称:OT_4010D,代码行数:46,代码来源:transapi.cpp
示例13: main
int main(int argc, char **argv) {
Calendar *cal;
DateFormat *fmt;
DateFormat *defFmt;
Transliterator *greek_latin;
Transliterator *rbtUnaccent;
Transliterator *unaccent;
UParseError pError;
UErrorCode status = U_ZERO_ERROR;
Locale greece("el", "GR");
UnicodeString str, str2;
// Create a calendar in the Greek locale
cal = Calendar::createInstance(greece, status);
check(status, "Calendar::createInstance");
// Create a formatter
fmt = DateFormat::createDateInstance(DateFormat::kFull, greece);
fmt->setCalendar(*cal);
// Create a default formatter
defFmt = DateFormat::createDateInstance(DateFormat::kFull);
defFmt->setCalendar(*cal);
// Create a Greek-Latin Transliterator
greek_latin = Transliterator::createInstance("Greek-Latin", UTRANS_FORWARD, status);
if (greek_latin == 0) {
printf("ERROR: Transliterator::createInstance() failed\n");
exit(1);
}
// Create a custom Transliterator
rbtUnaccent = Transliterator::createFromRules("RBTUnaccent",
UNACCENT_RULES,
UTRANS_FORWARD,
pError,
status);
check(status, "Transliterator::createFromRules");
// Create a custom Transliterator
unaccent = new UnaccentTransliterator();
// Loop over various months
for (int32_t month = Calendar::JANUARY;
month <= Calendar::DECEMBER;
++month) {
// Set the calendar to a date
cal->clear();
cal->set(1999, month, 4);
// Format the date in default locale
str.remove();
defFmt->format(cal->getTime(status), str, status);
check(status, "DateFormat::format");
printf("Date: ");
uprintf(escape(str));
printf("\n");
// Format the date for Greece
str.remove();
fmt->format(cal->getTime(status), str, status);
check(status, "DateFormat::format");
printf("Greek formatted date: ");
uprintf(escape(str));
printf("\n");
// Transliterate result
greek_latin->transliterate(str);
printf("Transliterated via Greek-Latin: ");
uprintf(escape(str));
printf("\n");
// Transliterate result
str2 = str;
rbtUnaccent->transliterate(str);
printf("Transliterated via RBT unaccent: ");
uprintf(escape(str));
printf("\n");
unaccent->transliterate(str2);
printf("Transliterated via normalizer unaccent: ");
uprintf(escape(str2));
printf("\n\n");
}
// Clean up
delete fmt;
delete cal;
delete greek_latin;
delete unaccent;
delete rbtUnaccent;
printf("Exiting successfully\n");
return 0;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:97,代码来源:main.cpp
示例14: 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
示例15: sizeof
//.........这里部分代码省略.........
"\\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);
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:67,代码来源:jamotest.cpp
示例16: switch
Transliterator* TransliteratorAlias::create(UParseError& pe,
UErrorCode& ec) {
if (U_FAILURE(ec)) {
return 0;
}
Transliterator *t = NULL;
switch (type) {
case SIMPLE:
t = Transliterator::createInstance(aliasesOrRules, UTRANS_FORWARD, pe, ec);
if(U_FAILURE(ec)){
return 0;
}
if (compoundFilter != 0)
t->adoptFilter((UnicodeSet*)compoundFilter->clone());
break;
case COMPOUND:
{
// the total number of transliterators in the compound is the total number of anonymous transliterators
// plus the total number of ID blocks-- we start by assuming the list begins and ends with an ID
// block and that each pair anonymous transliterators has an ID block between them. Then we go back
// to see whether there really are ID blocks at the beginning and end (by looking for U+FFFF, which
// marks the position where an anonymous transliterator goes) and adjust accordingly
int32_t anonymousRBTs = transes->size();
int32_t transCount = anonymousRBTs * 2 + 1;
if (!aliasesOrRules.isEmpty() && aliasesOrRules[0] == (UChar)(0xffff))
--transCount;
if (aliasesOrRules.length() >= 2 && aliasesOrRules[aliasesOrRules.length() - 1] == (UChar)(0xffff))
--transCount;
UnicodeString noIDBlock((UChar)(0xffff));
noIDBlock += ((UChar)(0xffff));
int32_t pos = aliasesOrRules.indexOf(noIDBlock);
while (pos >= 0) {
--transCount;
pos = aliasesOrRules.indexOf(noIDBlock, pos + 1);
}
UVector transliterators(ec);
UnicodeString idBlock;
int32_t blockSeparatorPos = aliasesOrRules.indexOf((UChar)(0xffff));
while (blockSeparatorPos >= 0) {
aliasesOrRules.extract(0, blockSeparatorPos, idBlock);
aliasesOrRules.remove(0, blockSeparatorPos + 1);
if (!idBlock.isEmpty())
transliterators.addElement(Transliterator::createInstance(idBlock, UTRANS_FORWARD, pe, ec), ec);
if (!transes->isEmpty())
transliterators.addElement(transes->orphanElementAt(0), ec);
blockSeparatorPos = aliasesOrRules.indexOf((UChar)(0xffff));
}
if (!aliasesOrRules.isEmpty())
transliterators.addElement(Transliterator::createInstance(aliasesOrRules, UTRANS_FORWARD, pe, ec), ec);
while (!transes->isEmpty())
transliterators.addElement(transes->orphanElementAt(0), ec);
if (U_SUCCESS(ec)) {
t = new CompoundTransliterator(ID, transliterators,
(compoundFilter ? (UnicodeSet*)(compoundFilter->clone()) : 0),
anonymousRBTs, pe, ec);
if (t == 0) {
ec = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
} else {
for (int32_t i = 0; i < transliterators.size(); i++)
delete (Transliterator*)(transliterators.elementAt(i));
}
}
break;
case RULES:
U_ASSERT(FALSE); // don't call create() if isRuleBased() returns TRUE!
break;
}
return t;
}
开发者ID:GuillaumeSmaha,项目名称:stringi,代码行数:73,代码来源:transreg.cpp
示例17: umtx_lock
Transliterator* Transliterator::createBasicInstance(const UnicodeString& id,
const UnicodeString* canon) {
UParseError pe;
UErrorCode ec = U_ZERO_ERROR;
TransliteratorAlias* alias = 0;
Transliterator* t = 0;
umtx_lock(®istryMutex);
if (HAVE_REGISTRY(ec)) {
t = registry->get(id, alias, ec);
}
umtx_unlock(®istryMutex);
if (U_FAILURE(ec)) {
delete t;
delete alias;
return 0;
}
// We may have not gotten a transliterator: Because we can't
// instantiate a transliterator from inside TransliteratorRegistry::
// get() (that would deadlock), we sometimes pass back an alias. This
// contains the data we need to finish the instantiation outside the
// registry mutex. The alias may, in turn, generate another alias, so
// we handle aliases in a loop. The max times through the loop is two.
// [alan]
while (alias != 0) {
U_ASSERT(t==0);
// Rule-based aliases are handled with TransliteratorAlias::
// parse(), followed by TransliteratorRegistry::reget().
// Other aliases are handled with TransliteratorAlias::create().
if (alias->isRuleBased()) {
// Step 1. parse
TransliteratorParser parser(ec);
alias->parse(parser, pe, ec);
delete alias;
alias = 0;
// Step 2. reget
umtx_lock(®istryMutex);
if (HAVE_REGISTRY(ec)) {
t = registry->reget(id, parser, alias, ec);
}
umtx_unlock(®istryMutex);
// Step 3. Loop back around!
} else {
t = alias->create(pe, ec);
delete alias;
alias = 0;
break;
}
if (U_FAILURE(ec)) {
delete t;
delete alias;
t = NULL;
break;
}
}
if (t != NULL && canon != NULL) {
t->setID(*canon);
}
return t;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:66,代码来源:translit.cpp
示例18: convertFile
// Convert a file from one encoding to another
static UBool convertFile(const char *pname,
const char *fromcpage,
UConverterToUCallback toucallback,
const void *touctxt,
const char *tocpage,
UConverterFromUCallback fromucallback,
const void *fromuctxt,
int fallback,
size_t bufsz,
const char *translit,
const char *infilestr,
FILE * outfile, int verbose)
{
FILE *infile;
UBool ret = TRUE;
UConverter *convfrom = 0;
UConverter *convto = 0;
UErrorCode err = U_ZERO_ERROR;
UBool flush;
const char *cbufp;
char *bufp;
char *buf = 0;
uint32_t infoffset = 0, outfoffset = 0; /* Where we are in the file, for error reporting. */
const UChar *unibufbp;
UChar *unibufp;
UChar *unibuf = 0;
int32_t *fromoffsets = 0, *tooffsets = 0;
size_t rd, wr, tobufsz;
#if !UCONFIG_NO_TRANSLITERATION
Transliterator *t = 0; // Transliterator acting on Unicode data.
#endif
UnicodeString u; // String to do the transliteration.
// Open the correct input file or connect to stdin for reading input
if (infilestr != 0 && strcmp(infilestr, "-")) {
infile = fopen(infilestr, "rb");
if (infile == 0) {
UnicodeString str1(infilestr, "");
str1.append((UChar32) 0);
UnicodeString str2(strerror(errno), "");
str2.append((UChar32) 0);
initMsg(pname);
u_wmsg(stderr, "cantOpenInputF", str1.getBuffer(), str2.getBuffer());
return FALSE;
}
} else {
infilestr = "-";
infile = stdin;
#ifdef WIN32
if (setmode(fileno(stdin), O_BINARY) == -1) {
initMsg(pname);
u_wmsg(stderr, "cantSetInBinMode");
return FALSE;
}
#endif
}
if (verbose) {
fprintf(stderr, "%s:\n", infilestr);
}
#if !UCONFIG_NO_TRANSLITERATION
// Create transliterator as needed.
if (translit != NULL && *translit) {
UParseError parse;
UnicodeString str(translit), pestr;
/* Create from rules or by ID as needed. */
parse.line = -1;
if (uprv_strchr(translit, ':') || uprv_strchr(translit, '>') || uprv_strchr(translit, '<') || uprv_strchr(translit, '>')) {
t = Transliterator::createFromRules("Uconv", str, UTRANS_FORWARD, parse, err);
} else {
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) {
//.........这里部分代码省略.........
开发者ID:gitpan,项目名称:ponie,代码行数:101,代码来源:uconv.cpp
示例19: parser
Transliterator* U_EXPORT2
Transliterator::createFromRules(const UnicodeString& ID,
const UnicodeString& rules,
UTransDirection dir,
UParseError& parseError,
UErrorCode& status)
{
Transliterator* t = NULL;
TransliteratorParser parser(status);
parser.parse(rules, dir, parseError, status);
if (U_FAILURE(status)) {
return 0;
}
// NOTE: The logic here matches that in TransliteratorRegistry.
if (parser.idBlockVector.size() == 0 && parser.dataVector.size() == 0) {
t = new NullTransliterator();
}
else if (parser.idBlockVector.size() == 0 && parser.dataVector.size() == 1) {
t = new RuleBasedTransliterator(ID, (TransliterationRuleData*)parser.dataVector.orphanElementAt(0), TRUE);
}
else if (parser.idBlockVector.size() == 1 && parser.dataVector.size() == 0) {
// idBlock, no data -- this is an alias. The ID has
// been munged from reverse into forward mode, if
// necessary, so instantiate the ID in the forward
// direction.
if (parser.compoundFilter != NULL) {
UnicodeString filterPattern;
parser.compoundFilter->toPattern(filterPattern, FALSE);
t = createInstance(filterPattern + UnicodeString(ID_DELIM)
+ *((UnicodeString*)parser.idBlockVector.eleme
|
请发表评论