]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/unicode/ushape.h
2 ******************************************************************************
4 * Copyright (C) 2000-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2000jun29
14 * created by: Markus W. Scherer
20 #include "unicode/utypes.h"
24 * \brief C API: Arabic shaping
29 * Shape Arabic text on a character basis.
31 * <p>This function performs basic operations for "shaping" Arabic text. It is most
32 * useful for use with legacy data formats and legacy display technology
33 * (simple terminals). All operations are performed on Unicode characters.</p>
35 * <p>Text-based shaping means that some character code points in the text are
36 * replaced by others depending on the context. It transforms one kind of text
37 * into another. In comparison, modern displays for Arabic text select
38 * appropriate, context-dependent font glyphs for each text element, which means
39 * that they transform text into a glyph vector.</p>
41 * <p>Text transformations are necessary when modern display technology is not
42 * available or when text needs to be transformed to or from legacy formats that
43 * use "shaped" characters. Since the Arabic script is cursive, connecting
44 * adjacent letters to each other, computers select images for each letter based
45 * on the surrounding letters. This usually results in four images per Arabic
46 * letter: initial, middle, final, and isolated forms. In Unicode, on the other
47 * hand, letters are normally stored abstract, and a display system is expected
48 * to select the necessary glyphs. (This makes searching and other text
49 * processing easier because the same letter has only one code.) It is possible
50 * to mimic this with text transformations because there are characters in
51 * Unicode that are rendered as letters with a specific shape
52 * (or cursive connectivity). They were included for interoperability with
53 * legacy systems and codepages, and for unsophisticated display systems.</p>
55 * <p>A second kind of text transformations is supported for Arabic digits:
56 * For compatibility with legacy codepages that only include European digits,
57 * it is possible to replace one set of digits by another, changing the
58 * character code points. These operations can be performed for either
59 * Arabic-Indic Digits (U+0660...U+0669) or Eastern (Extended) Arabic-Indic
60 * digits (U+06f0...U+06f9).</p>
62 * <p>Some replacements may result in more or fewer characters (code points).
63 * By default, this means that the destination buffer may receive text with a
64 * length different from the source length. Some legacy systems rely on the
65 * length of the text to be constant. They expect extra spaces to be added
66 * or consumed either next to the affected character or at the end of the
69 * <p>For details about the available operations, see the description of the
70 * <code>U_SHAPE_...</code> options.</p>
72 * @param source The input text.
74 * @param sourceLength The number of UChars in <code>source</code>.
76 * @param dest The destination buffer that will receive the results of the
77 * requested operations. It may be <code>NULL</code> only if
78 * <code>destSize</code> is 0. The source and destination must not
81 * @param destSize The size (capacity) of the destination buffer in UChars.
82 * If <code>destSize</code> is 0, then no output is produced,
83 * but the necessary buffer size is returned ("preflighting").
85 * @param options This is a 32-bit set of flags that specify the operations
86 * that are performed on the input text. If no error occurs,
87 * then the result will always be written to the destination
90 * @param pErrorCode must be a valid pointer to an error code value,
91 * which must not indicate a failure before the function call.
93 * @return The number of UChars written to the destination buffer.
94 * If an error occured, then no output was written, or it may be
95 * incomplete. If <code>U_BUFFER_OVERFLOW_ERROR</code> is set, then
96 * the return value indicates the necessary destination buffer size.
99 U_STABLE
int32_t U_EXPORT2
100 u_shapeArabic(const UChar
*source
, int32_t sourceLength
,
101 UChar
*dest
, int32_t destSize
,
103 UErrorCode
*pErrorCode
);
106 * Memory option: allow the result to have a different length than the source.
109 #define U_SHAPE_LENGTH_GROW_SHRINK 0
112 * Memory option: the result must have the same length as the source.
113 * If more room is necessary, then try to consume spaces next to modified characters.
116 #define U_SHAPE_LENGTH_FIXED_SPACES_NEAR 1
119 * Memory option: the result must have the same length as the source.
120 * If more room is necessary, then try to consume spaces at the end of the text.
123 #define U_SHAPE_LENGTH_FIXED_SPACES_AT_END 2
126 * Memory option: the result must have the same length as the source.
127 * If more room is necessary, then try to consume spaces at the beginning of the text.
130 #define U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING 3
132 /** Bit mask for memory options. @stable ICU 2.0 */
133 #define U_SHAPE_LENGTH_MASK 3
136 /** Direction indicator: the source is in logical (keyboard) order. @stable ICU 2.0 */
137 #define U_SHAPE_TEXT_DIRECTION_LOGICAL 0
140 * Direction indicator:
141 * the source is in visual LTR order,
142 * the leftmost displayed character stored first.
145 #define U_SHAPE_TEXT_DIRECTION_VISUAL_LTR 4
147 /** Bit mask for direction indicators. @stable ICU 2.0 */
148 #define U_SHAPE_TEXT_DIRECTION_MASK 4
151 /** Letter shaping option: do not perform letter shaping. @stable ICU 2.0 */
152 #define U_SHAPE_LETTERS_NOOP 0
154 /** Letter shaping option: replace abstract letter characters by "shaped" ones. @stable ICU 2.0 */
155 #define U_SHAPE_LETTERS_SHAPE 8
157 /** Letter shaping option: replace "shaped" letter characters by abstract ones. @stable ICU 2.0 */
158 #define U_SHAPE_LETTERS_UNSHAPE 0x10
161 * Letter shaping option: replace abstract letter characters by "shaped" ones.
162 * The only difference with U_SHAPE_LETTERS_SHAPE is that Tashkeel letters
163 * are always "shaped" into the isolated form instead of the medial form
164 * (selecting code points from the Arabic Presentation Forms-B block).
167 #define U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED 0x18
169 /** Bit mask for letter shaping options. @stable ICU 2.0 */
170 #define U_SHAPE_LETTERS_MASK 0x18
173 /** Digit shaping option: do not perform digit shaping. @stable ICU 2.0 */
174 #define U_SHAPE_DIGITS_NOOP 0
177 * Digit shaping option:
178 * Replace European digits (U+0030...) by Arabic-Indic digits.
181 #define U_SHAPE_DIGITS_EN2AN 0x20
184 * Digit shaping option:
185 * Replace Arabic-Indic digits by European digits (U+0030...).
188 #define U_SHAPE_DIGITS_AN2EN 0x40
191 * Digit shaping option:
192 * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent
193 * strongly directional character is an Arabic letter
194 * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>
195 * The direction of "preceding" depends on the direction indicator option.
196 * For the first characters, the preceding strongly directional character
197 * (initial state) is assumed to be not an Arabic letter
198 * (it is <code>U_LEFT_TO_RIGHT</code> [L] or <code>U_RIGHT_TO_LEFT</code> [R]).
201 #define U_SHAPE_DIGITS_ALEN2AN_INIT_LR 0x60
204 * Digit shaping option:
205 * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent
206 * strongly directional character is an Arabic letter
207 * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>
208 * The direction of "preceding" depends on the direction indicator option.
209 * For the first characters, the preceding strongly directional character
210 * (initial state) is assumed to be an Arabic letter.
213 #define U_SHAPE_DIGITS_ALEN2AN_INIT_AL 0x80
215 /** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */
216 #define U_SHAPE_DIGITS_RESERVED 0xa0
218 /** Bit mask for digit shaping options. @stable ICU 2.0 */
219 #define U_SHAPE_DIGITS_MASK 0xe0
222 /** Digit type option: Use Arabic-Indic digits (U+0660...U+0669). @stable ICU 2.0 */
223 #define U_SHAPE_DIGIT_TYPE_AN 0
225 /** Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9). @stable ICU 2.0 */
226 #define U_SHAPE_DIGIT_TYPE_AN_EXTENDED 0x100
228 /** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */
229 #define U_SHAPE_DIGIT_TYPE_RESERVED 0x200
231 /** Bit mask for digit type options. @stable ICU 2.0 */
232 #define U_SHAPE_DIGIT_TYPE_MASK 0x3f00