[sword-cvs] sword/src/modules/filters utf8hebrewpoints.cpp,1.7,1.8 utf8nfc.cpp,1.6,1.7 utf8nfkd.cpp,1.6,1.7
sword@www.crosswire.org
sword@www.crosswire.org
Sat, 22 Feb 2003 14:36:45 -0700
Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv6569/src/modules/filters
Modified Files:
utf8hebrewpoints.cpp utf8nfc.cpp utf8nfkd.cpp
Log Message:
converted to SWBuf stuff
Index: utf8hebrewpoints.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8hebrewpoints.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** utf8hebrewpoints.cpp 1 Oct 2002 19:52:40 -0000 1.7
--- utf8hebrewpoints.cpp 22 Feb 2003 21:36:43 -0000 1.8
***************
*** 35,56 ****
}
! char UTF8HebrewPoints::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 0xB0 to 0xD6 0xBF excluding 0xD6 0x consist of Hebrew cantillation marks so block those out.
! for (from = (unsigned char*)text; *from; from++) {
if ((*from == 0xD6) && (*(from + 1) >= 0xB0 && *(from + 1) <= 0xBF) && (*(from + 1) != 0xBE)) {
from++;
}
else {
! *to++ = *from;
}
}
! *to++ = 0;
! *to = 0;
! }
return 0;
}
--- 35,53 ----
}
! char UTF8HebrewPoints::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (!option) {
//The UTF-8 range 0xD6 0xB0 to 0xD6 0xBF excluding 0xD6 0x 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) && (*(from + 1) >= 0xB0 && *(from + 1) <= 0xBF) && (*(from + 1) != 0xBE)) {
from++;
}
else {
! text += *from;
}
}
! }
return 0;
}
Index: utf8nfc.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8nfc.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** utf8nfc.cpp 1 Oct 2002 19:52:40 -0000 1.6
--- utf8nfc.cpp 22 Feb 2003 21:36:43 -0000 1.7
***************
*** 26,38 ****
}
! char UTF8NFC::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return -1;
! int32_t len = strlen(text) * 2;
source = new UChar[len + 1]; //each char could become a surrogate pair
// Convert UTF-8 string to UTF-16 (UChars)
! len = ucnv_toUChars(conv, source, len, text, -1, &err);
target = new UChar[len + 1];
--- 26,39 ----
}
! char UTF8NFC::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return -1;
!
! int32_t len = text.length() * 2;
source = new UChar[len + 1]; //each char could become a surrogate pair
// Convert UTF-8 string to UTF-16 (UChars)
! len = ucnv_toUChars(conv, source, len, text.c_str(), -1, &err);
target = new UChar[len + 1];
***************
*** 40,44 ****
unorm_normalize(source, len, UNORM_NFC, 0, target, len, &err);
! ucnv_fromUChars(conv, text, maxlen, target, -1, &err);
delete [] source;
--- 41,45 ----
unorm_normalize(source, len, UNORM_NFC, 0, target, len, &err);
! ucnv_fromUChars(conv, text.c_str(), maxlen, target, -1, &err);
delete [] source;
Index: utf8nfkd.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8nfkd.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** utf8nfkd.cpp 1 Oct 2002 19:52:40 -0000 1.6
--- utf8nfkd.cpp 22 Feb 2003 21:36:43 -0000 1.7
***************
*** 26,38 ****
}
! char UTF8NFKD::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
! if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return -1;
! int32_t len = strlen(text) * 2;
source = new UChar[len + 1]; //each char could become a surrogate pair
// Convert UTF-8 string to UTF-16 (UChars)
! len = ucnv_toUChars(conv, source, len, text, -1, &err);
target = new UChar[len + 1];
--- 26,39 ----
}
! char UTF8NFKD::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
! if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return -1;
!
! int32_t len = text.length() * 2;
source = new UChar[len + 1]; //each char could become a surrogate pair
// Convert UTF-8 string to UTF-16 (UChars)
! len = ucnv_toUChars(conv, source, len, text.c_str(), -1, &err);
target = new UChar[len + 1];
***************
*** 40,44 ****
unorm_normalize(source, len, UNORM_NFKD, 0, target, len, &err);
! ucnv_fromUChars(conv, text, maxlen, target, -1, &err);
delete [] source;
--- 41,45 ----
unorm_normalize(source, len, UNORM_NFKD, 0, target, len, &err);
! ucnv_fromUChars(conv, text.c_str(), maxlen, target, -1, &err);
delete [] source;