ICU 75.1 75.1

utrans.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 1997-2011,2014-2015 International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * Date Name Description
9 * 06/21/00 aliu Creation.
10 *******************************************************************************
11 */
12
13 #ifndef UTRANS_H
14 #define UTRANS_H
15
16 #include "unicode/utypes.h"
17
18 #if !UCONFIG_NO_TRANSLITERATION
19
20 #include "unicode/urep.h"
21 #include "unicode/parseerr.h"
22 #include "unicode/uenum.h"
23 #include "unicode/uset.h"
24
25 #if U_SHOW_CPLUSPLUS_API
26 #include "unicode/localpointer.h"
27 #endif // U_SHOW_CPLUSPLUS_API
28
29 /********************************************************************
30 * General Notes
31 ********************************************************************
32 */
62 /********************************************************************
63 * Data Structures
64 ********************************************************************/
65
73 typedef void* UTransliterator;
74
83 typedef enum UTransDirection {
84
91 UTRANS_FORWARD,
92
99 UTRANS_REVERSE
100
101 } UTransDirection;
102
125 typedef struct UTransPosition {
126
135 int32_t contextStart;
136
145 int32_t contextLimit;
146
154 int32_t start;
155
163 int32_t limit;
164
165 } UTransPosition;
166
167 /********************************************************************
168 * General API
169 ********************************************************************/
170
194 U_CAPI UTransliterator* U_EXPORT2
195 utrans_openU(const UChar *id,
196 int32_t idLength,
197 UTransDirection dir,
198 const UChar *rules,
199 int32_t rulesLength,
200 UParseError *parseError,
201 UErrorCode *pErrorCode);
202
218 U_CAPI UTransliterator* U_EXPORT2
219 utrans_openInverse(const UTransliterator* trans,
220 UErrorCode* status);
221
232 U_CAPI UTransliterator* U_EXPORT2
233 utrans_clone(const UTransliterator* trans,
234 UErrorCode* status);
235
242 U_CAPI void U_EXPORT2
243 utrans_close(UTransliterator* trans);
244
245 #if U_SHOW_CPLUSPLUS_API
246
247 U_NAMESPACE_BEGIN
248
258 U_DEFINE_LOCAL_OPEN_POINTER(LocalUTransliteratorPointer, UTransliterator, utrans_close);
259
260 U_NAMESPACE_END
261
262 #endif
263
278 U_CAPI const UChar * U_EXPORT2
279 utrans_getUnicodeID(const UTransliterator *trans,
280 int32_t *resultLength);
281
296 U_CAPI void U_EXPORT2
297 utrans_register(UTransliterator* adoptedTrans,
298 UErrorCode* status);
299
309 U_CAPI void U_EXPORT2
310 utrans_unregisterID(const UChar* id, int32_t idLength);
311
330 U_CAPI void U_EXPORT2
331 utrans_setFilter(UTransliterator* trans,
332 const UChar* filterPattern,
333 int32_t filterPatternLen,
334 UErrorCode* status);
335
343 U_CAPI int32_t U_EXPORT2
344 utrans_countAvailableIDs(void);
345
355 U_CAPI UEnumeration * U_EXPORT2
356 utrans_openIDs(UErrorCode *pErrorCode);
357
358 /********************************************************************
359 * Transliteration API
360 ********************************************************************/
361
385 U_CAPI void U_EXPORT2
386 utrans_trans(const UTransliterator* trans,
387 UReplaceable* rep,
388 const UReplaceableCallbacks* repFunc,
389 int32_t start,
390 int32_t* limit,
391 UErrorCode* status);
392
436 U_CAPI void U_EXPORT2
437 utrans_transIncremental(const UTransliterator* trans,
438 UReplaceable* rep,
439 const UReplaceableCallbacks* repFunc,
440 UTransPosition* pos,
441 UErrorCode* status);
442
473 U_CAPI void U_EXPORT2
474 utrans_transUChars(const UTransliterator* trans,
475 UChar* text,
476 int32_t* textLength,
477 int32_t textCapacity,
478 int32_t start,
479 int32_t* limit,
480 UErrorCode* status);
481
508 U_CAPI void U_EXPORT2
509 utrans_transIncrementalUChars(const UTransliterator* trans,
510 UChar* text,
511 int32_t* textLength,
512 int32_t textCapacity,
513 UTransPosition* pos,
514 UErrorCode* status);
515
533 U_CAPI int32_t U_EXPORT2
534 utrans_toRules( const UTransliterator* trans,
535 UBool escapeUnprintable,
536 UChar* result, int32_t resultLength,
537 UErrorCode* status);
538
558 U_CAPI USet* U_EXPORT2
559 utrans_getSourceSet(const UTransliterator* trans,
560 UBool ignoreFilter,
561 USet* fillIn,
562 UErrorCode* status);
563
564 /* deprecated API ----------------------------------------------------------- */
565
566 #ifndef U_HIDE_DEPRECATED_API
567
568 /* see utrans.h documentation for why these functions are deprecated */
569
593 U_DEPRECATED UTransliterator* U_EXPORT2
594 utrans_open(const char* id,
595 UTransDirection dir,
596 const UChar* rules, /* may be Null */
597 int32_t rulesLength, /* -1 if null-terminated */
598 UParseError* parseError, /* may be Null */
599 UErrorCode* status);
600
616 U_DEPRECATED int32_t U_EXPORT2
617 utrans_getID(const UTransliterator* trans,
618 char* buf,
619 int32_t bufCapacity);
620
630 U_DEPRECATED void U_EXPORT2
631 utrans_unregister(const char* id);
632
651 U_DEPRECATED int32_t U_EXPORT2
652 utrans_getAvailableID(int32_t index,
653 char* buf,
654 int32_t bufCapacity);
655
656 #endif /* U_HIDE_DEPRECATED_API */
657
658 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
659
660 #endif
LocalUTransliteratorPointer
"Smart pointer" class, closes a UTransliterator via utrans_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
parseerr.h
C API: Parse Error Information.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
UReplaceableCallbacks
A set of function pointers that transliterators use to manipulate a UReplaceable.
Definition: urep.h:53
UTransPosition
Position structure for utrans_transIncremental() incremental transliteration.
Definition: utrans.h:125
UTransPosition::start
int32_t start
Beginning index, inclusive, of the text to be transliterated.
Definition: utrans.h:154
UTransPosition::contextLimit
int32_t contextLimit
Ending index, exclusive, of the context to be considered for a transliteration operation.
Definition: utrans.h:145
UTransPosition::contextStart
int32_t contextStart
Beginning index, inclusive, of the context to be considered for a transliteration operation.
Definition: utrans.h:135
UTransPosition::limit
int32_t limit
Ending index, exclusive, of the text to be transliterated.
Definition: utrans.h:163
uenum.h
C API: String Enumeration.
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:44
U_DEPRECATED
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API
Definition: umachine.h:116
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:378
urep.h
C API: Callbacks for UReplaceable.
UReplaceable
void * UReplaceable
An opaque replaceable text object.
Definition: urep.h:44
uset.h
C API: Unicode Set.
USet
struct USet USet
USet is the C API type corresponding to C++ class UnicodeSet.
Definition: uset.h:50
utrans_getSourceSet
U_CAPI USet * utrans_getSourceSet(const UTransliterator *trans, UBool ignoreFilter, USet *fillIn, UErrorCode *status)
Returns the set of all characters that may be modified in the input text by this UTransliterator,...
UTransDirection
UTransDirection
Direction constant indicating the direction in a transliterator, e.g., the forward or reverse rules o...
Definition: utrans.h:83
UTRANS_FORWARD
@ UTRANS_FORWARD
UTRANS_FORWARD means from <source> to <target> for a transliterator with ID <source>-<target>.
Definition: utrans.h:91
UTRANS_REVERSE
@ UTRANS_REVERSE
UTRANS_REVERSE means from <target> to <source> for a transliterator with ID <source>-<target>.
Definition: utrans.h:99
utrans_register
U_CAPI void utrans_register(UTransliterator *adoptedTrans, UErrorCode *status)
Register an open transliterator with the system.
UTransliterator
void * UTransliterator
An opaque transliterator for use in C.
Definition: utrans.h:73
utrans_trans
U_CAPI void utrans_trans(const UTransliterator *trans, UReplaceable *rep, const UReplaceableCallbacks *repFunc, int32_t start, int32_t *limit, UErrorCode *status)
Transliterate a segment of a UReplaceable string.
utrans_clone
U_CAPI UTransliterator * utrans_clone(const UTransliterator *trans, UErrorCode *status)
Create a copy of a transliterator.
utrans_setFilter
U_CAPI void utrans_setFilter(UTransliterator *trans, const UChar *filterPattern, int32_t filterPatternLen, UErrorCode *status)
Set the filter used by a transliterator.
utrans_transIncrementalUChars
U_CAPI void utrans_transIncrementalUChars(const UTransliterator *trans, UChar *text, int32_t *textLength, int32_t textCapacity, UTransPosition *pos, UErrorCode *status)
Transliterate the portion of the UChar* text buffer that can be transliterated unambiguously.
utrans_openIDs
U_CAPI UEnumeration * utrans_openIDs(UErrorCode *pErrorCode)
Return a UEnumeration for the available transliterators.
utrans_close
U_CAPI void utrans_close(UTransliterator *trans)
Close a transliterator.
utrans_getID
int32_t utrans_getID(const UTransliterator *trans, char *buf, int32_t bufCapacity)
Deprecated, use utrans_getUnicodeID() instead.
utrans_unregister
void utrans_unregister(const char *id)
Deprecated, use utrans_unregisterID() instead.
utrans_getAvailableID
int32_t utrans_getAvailableID(int32_t index, char *buf, int32_t bufCapacity)
Deprecated, use utrans_openIDs() instead.
utrans_openU
U_CAPI UTransliterator * utrans_openU(const UChar *id, int32_t idLength, UTransDirection dir, const UChar *rules, int32_t rulesLength, UParseError *parseError, UErrorCode *pErrorCode)
Open a custom transliterator, given a custom rules string OR a system transliterator,...
utrans_getUnicodeID
U_CAPI const UChar * utrans_getUnicodeID(const UTransliterator *trans, int32_t *resultLength)
Return the programmatic identifier for this transliterator.
UTransPosition
struct UTransPosition UTransPosition
Position structure for utrans_transIncremental() incremental transliteration.
utrans_openInverse
U_CAPI UTransliterator * utrans_openInverse(const UTransliterator *trans, UErrorCode *status)
Open an inverse of an existing transliterator.
utrans_toRules
U_CAPI int32_t utrans_toRules(const UTransliterator *trans, UBool escapeUnprintable, UChar *result, int32_t resultLength, UErrorCode *status)
Create a rule string that can be passed to utrans_openU to recreate this transliterator.
utrans_countAvailableIDs
U_CAPI int32_t utrans_countAvailableIDs(void)
Return the number of system transliterators.
utrans_transUChars
U_CAPI void utrans_transUChars(const UTransliterator *trans, UChar *text, int32_t *textLength, int32_t textCapacity, int32_t start, int32_t *limit, UErrorCode *status)
Transliterate a segment of a UChar* string.
utrans_transIncremental
U_CAPI void utrans_transIncremental(const UTransliterator *trans, UReplaceable *rep, const UReplaceableCallbacks *repFunc, UTransPosition *pos, UErrorCode *status)
Transliterate the portion of the UReplaceable text buffer that can be transliterated unambiguously.
utrans_unregisterID
U_CAPI void utrans_unregisterID(const UChar *id, int32_t idLength)
Unregister a transliterator from the system.
utrans_open
UTransliterator * utrans_open(const char *id, UTransDirection dir, const UChar *rules, int32_t rulesLength, UParseError *parseError, UErrorCode *status)
Deprecated, use utrans_openU() instead.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415