]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/utrans.cpp
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / i18n / utrans.cpp
index 3535117addecb3c7660a6d4fd43f510110428cb4..16a09bdcb6a9e225b93cf9db6e5da3e8c8e29193 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- *   Copyright (C) 1997-2004, International Business Machines
+ *   Copyright (C) 1997-2009, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
  *   Date        Name        Description
@@ -64,14 +64,14 @@ public:
      *
      * @draft ICU 2.2
      */
-    virtual inline UClassID getDynamicClassID() const;
+    virtual UClassID getDynamicClassID() const;
 
     /**
      * ICU "poor man's RTTI", returns a UClassID for this class.
      *
      * @draft ICU 2.2
      */
-    static inline UClassID U_EXPORT2 getStaticClassID();
+    static UClassID U_EXPORT2 getStaticClassID();
 
 protected:
 
@@ -166,15 +166,12 @@ utrans_openU(const UChar *id,
                               rules,
                               rulesLength); // r-o alias
 
-        RuleBasedTransliterator *trans = NULL;
-        trans = new RuleBasedTransliterator(ID, ruleStr, dir,
-                                            NULL, *parseError, *status);
-        if (trans == NULL) {
-            *status = U_MEMORY_ALLOCATION_ERROR;
-        } else if (U_FAILURE(*status)) {
-            delete trans;
-            trans = NULL;
+        Transliterator *trans = NULL;
+        trans = Transliterator::createFromRules(ID, ruleStr, dir, *parseError, *status); 
+        if(U_FAILURE(*status)) { 
+            return NULL;
         }
+
         return (UTransliterator*) trans;
     }
 }
@@ -186,7 +183,7 @@ utrans_open(const char* id,
             int32_t rulesLength,        /* -1 if null-terminated */ 
             UParseError* parseError,    /* may be Null */
             UErrorCode* status) {
-    UnicodeString ID(id, ""); // use invariant converter
+    UnicodeString ID(id, -1, US_INV); // use invariant converter
     return utrans_openU(ID.getBuffer(), ID.length(), dir,
                         rules, rulesLength,
                         parseError, status);
@@ -242,7 +239,7 @@ U_CAPI int32_t U_EXPORT2
 utrans_getID(const UTransliterator* trans,
              char* buf,
              int32_t bufCapacity) {
-    return ((Transliterator*) trans)->getID().extract(0, 0x7fffffff, buf, bufCapacity, "");
+    return ((Transliterator*) trans)->getID().extract(0, 0x7fffffff, buf, bufCapacity, US_INV);
 }
 
 U_CAPI void U_EXPORT2
@@ -261,7 +258,7 @@ utrans_unregisterID(const UChar* id, int32_t idLength) {
 
 U_CAPI void U_EXPORT2
 utrans_unregister(const char* id) {
-    UnicodeString ID(id, ""); // use invariant converter
+    UnicodeString ID(id, -1, US_INV); // use invariant converter
     Transliterator::unregister(ID);
 }
 
@@ -299,7 +296,7 @@ U_CAPI int32_t U_EXPORT2
 utrans_getAvailableID(int32_t index,
                       char* buf, // may be NULL
                       int32_t bufCapacity) {
-    return Transliterator::getAvailableID(index).extract(0, 0x7fffffff, buf, bufCapacity, "");
+    return Transliterator::getAvailableID(index).extract(0, 0x7fffffff, buf, bufCapacity, US_INV);
 }
 
 /* Transliterator UEnumeration ---------------------------------------------- */