From 304cfb33d6a903a5be03249662fdf4347cb34013 Mon Sep 17 00:00:00 2001 From: "smontagu@smontagu.org" Date: Thu, 28 Jun 2007 13:02:57 -0700 Subject: [PATCH] Improve the CHAR_IS_BIDI macro. Bug 240943, patch from an idea by Peter Kirk, r+sr=roc --- intl/unicharutil/util/nsBidiUtils.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/intl/unicharutil/util/nsBidiUtils.h b/intl/unicharutil/util/nsBidiUtils.h index fa687898711..441769c8c3d 100644 --- a/intl/unicharutil/util/nsBidiUtils.h +++ b/intl/unicharutil/util/nsBidiUtils.h @@ -221,9 +221,23 @@ #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)) -#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) ) ) +/** + * 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 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__ */