Improve the CHAR_IS_BIDI macro. Bug 240943, patch from an idea by Peter Kirk, r+sr=roc
authorsmontagu@smontagu.org
Thu, 28 Jun 2007 13:02:57 -0700
changeset 2928 0a0168f2f92e4fea29854c4ad52560fa045b1e55
parent 2927 afd6c6a1cf33a86e38694375b2ba2648f2c61cf7
child 2929 734b2179304173597282645ca749b2a04cae46c2
push idunknown
push userunknown
push dateunknown
bugs240943
milestone1.9a6pre
Improve the CHAR_IS_BIDI macro. Bug 240943, patch from an idea by Peter Kirk, r+sr=roc
intl/unicharutil/util/nsBidiUtils.h
--- a/intl/unicharutil/util/nsBidiUtils.h
+++ b/intl/unicharutil/util/nsBidiUtils.h
@@ -216,14 +216,28 @@
 
 #define IS_HEBREW_CHAR(c) (((0x0590 <= (c)) && ((c)<= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))
 #define IS_06_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
 #define IS_FE_CHAR(c) (((0xfb50 <= (c)) && ((c)<= 0xfbFF)) \
                        || ((0xfe70 <= (c)) && ((c)<= 0xfeFC)))
 #define IS_ARABIC_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
 #define IS_ARABIC_ALPHABETIC(c) (IS_ARABIC_CHAR(c) && \
                                 !(IS_HINDI_DIGIT(c) || IS_FARSI_DIGIT(c) || IS_ARABIC_SEPARATOR(c)))
-#define IS_CYPRIOT_CHAR(c) ((0x10800 <= (c)) && ((c) <=0x1083F))
+
+/**
+ * The codepoint ranges in the following macros are based on the blocks
+ *  allocated, or planned to be allocated, to right-to-left characters in the
+ *  BMP (Basic Multilingual Plane) and SMP (Supplementary Multilingual Plane)
+ *  according to
+ *  http://unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt and
+ *  http://www.unicode.org/roadmaps/
+ */
 
-#define CHAR_IS_BIDI(c) ( (IS_HINDI_DIGIT(c) ) || (IS_HEBREW_CHAR(c) ) \
-                        || (IS_06_CHAR(c) ) || (IS_FE_CHAR(c) ) \
-                        || (IS_CYPRIOT_CHAR(c) ) )
+#define IS_IN_BMP_RTL_BLOCK(c) ((0x590 <= (c)) && ((c) <= 0x8ff))
+#define IS_RTL_PRESENTATION_FORM(c) (((0xfb1d <= (c)) && ((c) <= 0xfdff)) || \
+                                     ((0xfe70 <= (c)) && ((c) <= 0xfefc)))
+#define IS_IN_SMP_RTL_BLOCK(c) ((0x10800 <= (c)) && ((c) <= 0x10fff))
+#define UCS2_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
+                              (IS_RTL_PRESENTATION_FORM(c)))
+#define UTF32_CHAR_IS_BIDI(c)  ((IS_IN_BMP_RTL_BLOCK(c)) || \
+                               (IS_RTL_PRESENTATION_FORM(c)) || \
+                               (IS_IN_SMP_RTL_BLOCK(c)))
 #endif  /* nsBidiUtils_h__ */