summaryrefslogtreecommitdiffstats
path: root/unicode/courier-unicode.h.in
diff options
context:
space:
mode:
authorSam Varshavchik2020-07-04 20:01:49 -0400
committerSam Varshavchik2020-07-12 15:56:45 -0400
commitacd2a932df810d7db2037e3962feb61ca21e2781 (patch)
tree8f8f3fc757ff93ba4e2ecd9730451ccf6d945055 /unicode/courier-unicode.h.in
parentd57946b6a21b33f26f189951e1c30ca901581b90 (diff)
downloadcourier-libs-acd2a932df810d7db2037e3962feb61ca21e2781.tar.bz2
Implement the Unicode bidirectional algorithm.
Diffstat (limited to 'unicode/courier-unicode.h.in')
-rw-r--r--unicode/courier-unicode.h.in39
1 files changed, 38 insertions, 1 deletions
diff --git a/unicode/courier-unicode.h.in b/unicode/courier-unicode.h.in
index 68ece2c..67f3bda 100644
--- a/unicode/courier-unicode.h.in
+++ b/unicode/courier-unicode.h.in
@@ -554,7 +554,32 @@ size_t unicode_wbscan_end(unicode_wbscan_info_t i);
** values.
**
** unicode_bidi_bracket_type() returns the same character and
-** UNICODE_BIDI_n if the given character does not have these properties,
+** UNICODE_BIDI_n if the given character does not have these properties.
+**
+** unicode_bidi_calc() implements the Unicode Bidirectional Algorithm up to
+** step L1.
+**
+** Parameters:
+**
+** - A pointer to char32_t, the Unicode string.
+**
+** - Number of characters in the char32_t string
+**
+** - A pointer to an array of unicode_bidi_level_t values. The caller is
+** responsible for allocating and deallocating this array, which has the
+** same size as the Unicode string (the second parameter).
+**
+** - An optional pointer to a unicode_bidi_level_t value, or a null pointer.
+** A pointer to UNICODE_BIDI_LR or UNICODE_BIDI_RL sets the default paragraph
+** direction level. A null pointer calculates the default paragraph direction
+** level based on the string, as specified by the "P" rules in the algorithm.
+**
+** unicode_bidi_calc() fills in the unicode_bidi_level_t array with the
+** values corresponding to the embedding level of the corresponding character,
+** as specified in the Unicode Bidirection Algorithm (even for left-to-right,
+** and odd for right-to-left). A value of UNICODE_BIDI_SKIP designates
+** directional markers (from step X9). These characters should be removed
+** before using unicode_bidi_reorder().
*/
typedef char unicode_bidi_bracket_type_t;
@@ -568,6 +593,18 @@ extern char32_t unicode_bidi_mirror(char32_t c);
extern char32_t unicode_bidi_bracket_type(char32_t c,
unicode_bidi_bracket_type_t *ret);
+
+typedef unsigned char unicode_bidi_level_t;
+
+#define UNICODE_BIDI_LR ((unicode_bidi_level_t)0)
+#define UNICODE_BIDI_RL ((unicode_bidi_level_t)1)
+#define UNICODE_BIDI_SKIP ((unicode_bidi_level_t)254)
+
+extern void unicode_bidi_calc(const char32_t *p, size_t n,
+ unicode_bidi_level_t *bufp,
+ const unicode_bidi_level_t *
+ initial_embedding_level);
+
/*
** A buffer that holds unicode characters, and dynamically grows as needed.
*/