[sword-cvs] sword/src/modules/filters utf8bidireorder.cpp,1.4,1.5 utf8arshaping.cpp,1.4,1.5 utf8cantillation.cpp,1.5,1.6

sword@www.crosswire.org sword@www.crosswire.org
Sat, 22 Feb 2003 05:23:21 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv29123

Modified Files:
	utf8bidireorder.cpp utf8arshaping.cpp utf8cantillation.cpp 
Log Message:
converted to SWBug stuff

Index: utf8bidireorder.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8bidireorder.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** utf8bidireorder.cpp	1 Oct 2002 19:52:40 -0000	1.4
--- utf8bidireorder.cpp	22 Feb 2003 12:23:19 -0000	1.5
***************
*** 28,42 ****
  }
  
! char UTF8BiDiReorder::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
          UChar *ustr, *ustr2;
! 	 if ((unsigned long)key < 2)	// hack, we're en(1)/de(0)ciphering
  		return -1;
          
!         int32_t len = strlen(text);
          ustr = new UChar[len]; //each char could become a surrogate pair
  
  	// Convert UTF-8 string to UTF-16 (UChars)
!         len = ucnv_toUChars(conv, ustr, len, text, -1, &err);
          ustr2 = new UChar[len];
  
--- 28,42 ----
  }
  
! char UTF8BiDiReorder::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
          UChar *ustr, *ustr2;
! 	if ((unsigned long)key < 2)	// hack, we're en(1)/de(0)ciphering
  		return -1;
          
!         int32_t len = text.length();
          ustr = new UChar[len]; //each char could become a surrogate pair
  
  	// Convert UTF-8 string to UTF-16 (UChars)
!         len = ucnv_toUChars(conv, ustr, len, text.c_str(), -1, &err);
          ustr2 = new UChar[len];
  
***************
*** 50,54 ****
  //                UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS, &err);
  
!         ucnv_fromUChars(conv, text, maxlen, ustr2, len, &err);
  
          delete [] ustr2;
--- 50,54 ----
  //                UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS, &err);
  
!         ucnv_fromUChars(conv, text.c_str(), maxlen, ustr2, len, &err);
  
          delete [] ustr2;

Index: utf8arshaping.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8arshaping.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** utf8arshaping.cpp	1 Oct 2002 19:52:40 -0000	1.4
--- utf8arshaping.cpp	22 Feb 2003 12:23:19 -0000	1.5
***************
*** 19,25 ****
  
  UTF8arShaping::UTF8arShaping() {
! 
!         conv = ucnv_open("UTF-8", &err);
! 
  }
  
--- 19,23 ----
  
  UTF8arShaping::UTF8arShaping() {
! 	conv = ucnv_open("UTF-8", &err);
  }
  
***************
*** 28,32 ****
  }
  
! char UTF8arShaping::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
          UChar *ustr, *ustr2;
--- 26,30 ----
  }
  
! char UTF8arShaping::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
          UChar *ustr, *ustr2;
***************
*** 34,47 ****
  		return -1;
  
!         int32_t len = strlen(text);
          ustr = new UChar[len];
          ustr2 = new UChar[len];
  
  	// Convert UTF-8 string to UTF-16 (UChars)
!         len = ucnv_toUChars(conv, ustr, len, text, -1, &err);
  
          len = u_shapeArabic(ustr, len, ustr2, len, U_SHAPE_LETTERS_SHAPE | U_SHAPE_DIGITS_EN2AN, &err);
  
!         ucnv_fromUChars(conv, text, maxlen, ustr2, len, &err);
  
          delete [] ustr2;
--- 32,45 ----
  		return -1;
  
!         int32_t len = text.length();
          ustr = new UChar[len];
          ustr2 = new UChar[len];
  
  	// Convert UTF-8 string to UTF-16 (UChars)
!         len = ucnv_toUChars(conv, ustr, len, text.c_str(), -1, &err);
  
          len = u_shapeArabic(ustr, len, ustr2, len, U_SHAPE_LETTERS_SHAPE | U_SHAPE_DIGITS_EN2AN, &err);
  
!         ucnv_fromUChars(conv, text.c_str(), maxlen, ustr2, len, &err);
  
          delete [] ustr2;

Index: utf8cantillation.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8cantillation.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** utf8cantillation.cpp	1 Oct 2002 19:52:40 -0000	1.5
--- utf8cantillation.cpp	22 Feb 2003 12:23:19 -0000	1.6
***************
*** 35,65 ****
  }
  
! char UTF8Cantillation::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
  	if (!option) {
! 	unsigned char *to, *from;
! 	to = (unsigned char*)text;
! 	//The UTF-8 range 0xD6 0x90 to 0xD6 0xAF and 0xD7 0x84 consist of Hebrew cantillation marks so block those out.
! 	for (from = (unsigned char*)text; *from; from++) {
! 	  if (*from != 0xD6) {
! 	    if (*from == 0xD7 && *(from + 1) == 0x84) {
! 	      from++;
! 	    }
! 	    else {
! 	      *to++ = *from;
! 	    }
! 	  }
! 	  else if (*(from + 1) < 0x90 || *(from + 1) > 0xAF) {
! 	    *to++ = *from;
! 	    from++;
! 	    *to++ = *from;
! 	  }
!           else {
!                 from++;
!           }
  	}
- 	*to++ = 0;
- 	*to = 0;
-      }
  	return 0;
  }
--- 35,63 ----
  }
  
! char UTF8Cantillation::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
  	if (!option) {
! 		//The UTF-8 range 0xD6 0x90 to 0xD6 0xAF and 0xD7 0x84 consist of Hebrew cantillation marks so block those out.
! 		SWBuf orig = text;
! 		const unsigned char* from = (unsigned char*)orig.c_str();
! 		for (text = ""; *from; from++) {
! 			if (*from != 0xD6) {
! 				if (*from == 0xD7 && *(from + 1) == 0x84) {
! 					from++;
! 				}
! 				else {
! 					text += *from;
! 				}
! 			}
! 			else if (*(from + 1) < 0x90 || *(from + 1) > 0xAF) {
! 				text += *from;
! 				from++;
! 				text += *from;
! 			}
! 			else {
! 				from++;
! 			}
! 		}
  	}
  	return 0;
  }