icu4c api proposal: Unicode IDs in utrans_ C API

Markus Scherer <[email protected]>
Newsgroups gmane.comp.lib.icu.general
Organization IBM
Message-ID <[email protected]>
The Transliterator C++ API uses UnicodeString IDs, while the C API uses char * IDs. This works for 
true and pure identifiers that these APIs were designed for, for example "Cyrillic-Latin". It does 
not work when the ID contains filters ("[:Script=Cyrl:]") or even a complete set of rules because 
then the ID string contains more than just "invariant" characters (see utypes.h).

I propose to deprecate (but keep) the old APIs, document that they do not work for IDs with filters 
or rules, and add new functions with the necessary behavior:

U_CAPI UTransliterator* U_EXPORT2
utrans_openU(const UChar *id, // must not be NULL
              int32_t idLength, // -1 for NUL-terminated ID
              UTransDirection dir,
              const UChar *rules, // can be NULL
              int32_t rulesLength, // -1 for NUL-terminated rules
              UParseError *parseError, // can be NULL
              UErrorCode *pErrorCode);

(const char *id -> const UChar *id + idLength)

U_CAPI const UChar *U_EXPORT2 // will be NUL-terminated
utrans_getUnicodeID(const UTransliterator *trans,
                     int32_t *resultLength); // can be NULL

U_CAPI void U_EXPORT2
utrans_unregisterID(const UChar* id, int32_t idLength);


U_CAPI UEnumeration * U_EXPORT2
utrans_openIDs(UErrorCode *pErrorCode);

(To replace utrans_getAvailableID().)

Expiration: 2003-jul-07

Sincerely,
markus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.