[sword-cvs] sword/src/modules/filters utf16utf8.cpp,1.8,1.9
sword@www.crosswire.org
sword@www.crosswire.org
Wed, 26 Feb 2003 12:48:44 -0700
Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv15020
Modified Files:
utf16utf8.cpp
Log Message:
changed to swbuf
Index: utf16utf8.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf16utf8.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** utf16utf8.cpp 1 Oct 2002 19:52:40 -0000 1.8
--- utf16utf8.cpp 26 Feb 2003 19:48:42 -0000 1.9
***************
*** 16,23 ****
! char UTF16UTF8::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
unsigned short *from;
- unsigned char *to;
int len;
--- 16,22 ----
! char UTF16UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
unsigned short *from;
int len;
***************
*** 28,32 ****
len = 0;
! from = (unsigned short*) text;
while (*from) {
len += 2;
--- 27,31 ----
len = 0;
! from = (unsigned short*) text.c_str();
while (*from) {
len += 2;
***************
*** 34,49 ****
}
! // shift string to right of buffer
! if (len < maxlen) {
! memmove(&text[maxlen - len], text, len);
! from = (unsigned short*)&text[maxlen - len];
! }
! else
! from = (unsigned short*)text;
!
// -------------------------------
! for (to = (unsigned char*)text; *from; from++) {
uchar = 0;
--- 33,43 ----
}
! SWBuf orig = text;
! from = (unsigned short*)orig.c_str();
!
// -------------------------------
! for (text = ""; *from; from++) {
uchar = 0;
***************
*** 71,94 ****
if (uchar < 0x80) {
! *to++ = uchar;
}
else if (uchar < 0x800) {
! *to++ = 0xc0 | (uchar >> 6);
! *to++ = 0x80 | (uchar & 0x3f);
}
else if (uchar < 0x10000) {
! *to++ = 0xe0 | (uchar >> 12);
! *to++ = 0x80 | (uchar >> 6) & 0x3f;
! *to++ = 0x80 | uchar & 0x3f;
}
else if (uchar < 0x200000) {
! *to++ = 0xF0 | (uchar >> 18);
! *to++ = 0x80 | (uchar >> 12) & 0x3F;
! *to++ = 0x80 | (uchar >> 6) & 0x3F;
! *to++ = 0x80 | uchar & 0x3F;
}
}
- *to++ = 0;
- *to = 0;
return 0;
--- 65,86 ----
if (uchar < 0x80) {
! text += uchar;
}
else if (uchar < 0x800) {
! text += 0xc0 | (uchar >> 6);
! text += 0x80 | (uchar & 0x3f);
}
else if (uchar < 0x10000) {
! text += 0xe0 | (uchar >> 12);
! text += 0x80 | (uchar >> 6) & 0x3f;
! text += 0x80 | uchar & 0x3f;
}
else if (uchar < 0x200000) {
! text += 0xF0 | (uchar >> 18);
! text += 0x80 | (uchar >> 12) & 0x3F;
! text += 0x80 | (uchar >> 6) & 0x3F;
! text += 0x80 | uchar & 0x3F;
}
}
return 0;