1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 2004-2014, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
10 * file name: ubidi_props.h
12 * tab size: 8 (not used)
15 * created on: 2004dec30
16 * created by: Markus W. Scherer
18 * Low-level Unicode bidi/shaping properties access.
21 #ifndef __UBIDI_PROPS_H__
22 #define __UBIDI_PROPS_H__
24 #include "unicode/utypes.h"
25 #include "unicode/uset.h"
32 /* library API -------------------------------------------------------------- */
35 typedef struct UBiDiProps UBiDiProps
;
37 U_CFUNC
const UBiDiProps
*
38 ubidi_getSingleton(void);
41 ubidi_addPropertyStarts(const UBiDiProps
*bdp
, const USetAdder
*sa
, UErrorCode
*pErrorCode
);
43 /* property access functions */
46 ubidi_getMaxValue(const UBiDiProps
*bdp
, UProperty which
);
49 ubidi_getClass(const UBiDiProps
*bdp
, UChar32 c
);
52 ubidi_isMirrored(const UBiDiProps
*bdp
, UChar32 c
);
55 ubidi_getMirror(const UBiDiProps
*bdp
, UChar32 c
);
58 ubidi_isBidiControl(const UBiDiProps
*bdp
, UChar32 c
);
61 ubidi_isJoinControl(const UBiDiProps
*bdp
, UChar32 c
);
64 ubidi_getJoiningType(const UBiDiProps
*bdp
, UChar32 c
);
67 ubidi_getJoiningGroup(const UBiDiProps
*bdp
, UChar32 c
);
69 U_CFUNC UBidiPairedBracketType
70 ubidi_getPairedBracketType(const UBiDiProps
*bdp
, UChar32 c
);
73 ubidi_getPairedBracket(const UBiDiProps
*bdp
, UChar32 c
);
75 /* file definitions --------------------------------------------------------- */
77 #define UBIDI_DATA_NAME "ubidi"
78 #define UBIDI_DATA_TYPE "icu"
81 #define UBIDI_FMT_0 0x42
82 #define UBIDI_FMT_1 0x69
83 #define UBIDI_FMT_2 0x44
84 #define UBIDI_FMT_3 0x69
86 /* indexes into indexes[] */
91 UBIDI_IX_MIRROR_LENGTH
,
95 UBIDI_IX_JG_START2
, /* new in format version 2.2, ICU 54 */
98 UBIDI_MAX_VALUES_INDEX
=15,
102 /* definitions for 16-bit bidi/shaping properties word ---------------------- */
105 /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */
106 UBIDI_JT_SHIFT
=5, /* joining type: 3 bits (7..5) */
108 UBIDI_BPT_SHIFT
=8, /* Bidi_Paired_Bracket_Type(bpt): 2 bits (9..8) */
110 UBIDI_JOIN_CONTROL_SHIFT
=10,
111 UBIDI_BIDI_CONTROL_SHIFT
=11,
113 UBIDI_IS_MIRRORED_SHIFT
=12, /* 'is mirrored' */
114 UBIDI_MIRROR_DELTA_SHIFT
=13, /* bidi mirroring delta: 3 bits (15..13) */
116 UBIDI_MAX_JG_SHIFT
=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */
119 #define UBIDI_CLASS_MASK 0x0000001f
120 #define UBIDI_JT_MASK 0x000000e0
121 #define UBIDI_BPT_MASK 0x00000300
123 #define UBIDI_MAX_JG_MASK 0x00ff0000
125 #define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK)
126 #define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1)
128 #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC
129 # define UBIDI_GET_MIRROR_DELTA(props) ((int16_t)(props)>>UBIDI_MIRROR_DELTA_SHIFT)
131 # define UBIDI_GET_MIRROR_DELTA(props) (int16_t)(((props)&0x8000) ? (((props)>>UBIDI_MIRROR_DELTA_SHIFT)|0xe000) : ((props)>>UBIDI_MIRROR_DELTA_SHIFT))
135 UBIDI_ESC_MIRROR_DELTA
=-4,
136 UBIDI_MIN_MIRROR_DELTA
=-3,
137 UBIDI_MAX_MIRROR_DELTA
=3
140 /* definitions for 32-bit mirror table entry -------------------------------- */
143 /* the source Unicode code point takes 21 bits (20..0) */
144 UBIDI_MIRROR_INDEX_SHIFT
=21,
145 UBIDI_MAX_MIRROR_INDEX
=0x7ff
148 #define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff)
150 #define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT)