ICU-3170 cope with bidi class changes for +-/ in Unicode 4.0.1
X-SVN-Rev: 14860
This commit is contained in:
parent
853a991c48
commit
c2ef9b9084
@ -23,7 +23,7 @@ dirPropNames[dirPropCount]={
|
|||||||
"LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN"
|
"LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN"
|
||||||
};
|
};
|
||||||
|
|
||||||
const UChar
|
UChar
|
||||||
charFromDirProp[dirPropCount]={
|
charFromDirProp[dirPropCount]={
|
||||||
/* L R EN ES ET AN CS B S WS ON */
|
/* L R EN ES ET AN CS B S WS ON */
|
||||||
0x61, 0x5d0, 0x30, 0x2f, 0x25, 0x660, 0x2c, 0xa, 0x9, 0x20, 0x26,
|
0x61, 0x5d0, 0x30, 0x2f, 0x25, 0x660, 0x2c, 0xa, 0x9, 0x20, 0x26,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* COPYRIGHT:
|
* COPYRIGHT:
|
||||||
* Copyright (c) 1997-2003, International Business Machines Corporation and
|
* Copyright (c) 1997-2004, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
/* file name: cbiditst.cpp
|
/* file name: cbiditst.cpp
|
||||||
@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
/* prototypes ---------------------------------------------------------------*/
|
/* prototypes ---------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
charFromDirPropTest(void);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doBiDiTest(void);
|
doBiDiTest(void);
|
||||||
|
|
||||||
@ -68,6 +71,9 @@ static void TestReorder(void);
|
|||||||
|
|
||||||
static const char *levelString="...............................................................";
|
static const char *levelString="...............................................................";
|
||||||
|
|
||||||
|
static void
|
||||||
|
initCharFromDirProps(void);
|
||||||
|
|
||||||
static UChar *
|
static UChar *
|
||||||
getStringFromDirProps(const uint8_t *dirProps, int32_t length);
|
getStringFromDirProps(const uint8_t *dirProps, int32_t length);
|
||||||
|
|
||||||
@ -80,6 +86,7 @@ void addComplexTest(TestNode** root);
|
|||||||
|
|
||||||
void
|
void
|
||||||
addComplexTest(TestNode** root) {
|
addComplexTest(TestNode** root) {
|
||||||
|
addTest(root, charFromDirPropTest, "complex/bidi/charFromDirPropTest");
|
||||||
addTest(root, doBiDiTest, "complex/bidi/BiDiTest");
|
addTest(root, doBiDiTest, "complex/bidi/BiDiTest");
|
||||||
addTest(root, doInverseBiDiTest, "complex/bidi/inverse");
|
addTest(root, doInverseBiDiTest, "complex/bidi/inverse");
|
||||||
addTest(root, TestReorder,"complex/bidi/TestReorder");
|
addTest(root, TestReorder,"complex/bidi/TestReorder");
|
||||||
@ -89,6 +96,21 @@ addComplexTest(TestNode** root) {
|
|||||||
addTest(root, doLOGICALArabicDeShapingTest, "complex/arabic-shaping/unshaping");
|
addTest(root, doLOGICALArabicDeShapingTest, "complex/arabic-shaping/unshaping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* verify that the exemplar characters have the expected bidi classes */
|
||||||
|
static void
|
||||||
|
charFromDirPropTest(void) {
|
||||||
|
int32_t i;
|
||||||
|
|
||||||
|
initCharFromDirProps();
|
||||||
|
|
||||||
|
for(i=0; i<U_CHAR_DIRECTION_COUNT; ++i) {
|
||||||
|
if(u_charDirection(charFromDirProp[i])!=(UCharDirection)i) {
|
||||||
|
log_err("u_charDirection(charFromDirProp[%d]=U+%04x)!=%d\n",
|
||||||
|
i, charFromDirProp[i], i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doBiDiTest() {
|
doBiDiTest() {
|
||||||
UBiDi *pBiDi, *pLine=NULL;
|
UBiDi *pBiDi, *pLine=NULL;
|
||||||
@ -1352,12 +1374,31 @@ doLOGICALArabicDeShapingTest() {
|
|||||||
|
|
||||||
/* helpers ------------------------------------------------------------------ */
|
/* helpers ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
static void
|
||||||
|
initCharFromDirProps() {
|
||||||
|
static const UVersionInfo ucd401={ 4, 0, 1, 0 };
|
||||||
|
static UVersionInfo ucdVersion={ 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
/* lazy initialization */
|
||||||
|
if(ucdVersion[0]>0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_getUnicodeVersion(ucdVersion);
|
||||||
|
if(memcmp(ucdVersion, ucd401, sizeof(UVersionInfo))>0) {
|
||||||
|
/* Unicode 4.0.1 changes bidi classes for +-/ */
|
||||||
|
charFromDirProp[U_EUROPEAN_NUMBER_SEPARATOR]=0x2b; /* change ES character from / to + */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* return a string with characters according to the desired directional properties */
|
/* return a string with characters according to the desired directional properties */
|
||||||
static UChar *
|
static UChar *
|
||||||
getStringFromDirProps(const uint8_t *dirProps, int32_t length) {
|
getStringFromDirProps(const uint8_t *dirProps, int32_t length) {
|
||||||
static UChar s[MAX_STRING_LENGTH];
|
static UChar s[MAX_STRING_LENGTH];
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
|
||||||
|
initCharFromDirProps();
|
||||||
|
|
||||||
/* this part would have to be modified for UTF-x */
|
/* this part would have to be modified for UTF-x */
|
||||||
for(i=0; i<length; ++i) {
|
for(i=0; i<length; ++i) {
|
||||||
s[i]=charFromDirProp[dirProps[i]];
|
s[i]=charFromDirProp[dirProps[i]];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/********************************************************************
|
/********************************************************************
|
||||||
* COPYRIGHT:
|
* COPYRIGHT:
|
||||||
* Copyright (c) 1997-2001, International Business Machines Corporation and
|
* Copyright (c) 1997-2004, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
/* file name: cbiditst.h
|
/* file name: cbiditst.h
|
||||||
@ -58,7 +58,7 @@ enum {
|
|||||||
extern const char *
|
extern const char *
|
||||||
dirPropNames[dirPropCount];
|
dirPropNames[dirPropCount];
|
||||||
|
|
||||||
extern const UChar
|
extern UChar
|
||||||
charFromDirProp[dirPropCount];
|
charFromDirProp[dirPropCount];
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user