[sword-cvs] sword/src/utilfuns utilstr.cpp,1.27,1.28

sword@www.crosswire.org sword@www.crosswire.org
Sat, 17 Apr 2004 10:16:19 -0700


Update of /cvs/core/sword/src/utilfuns
In directory www:/tmp/cvs-serv8616/src/utilfuns

Modified Files:
	utilstr.cpp 
Log Message:
Added StringMgr to allow frontend side unicode handling; breaks no code; IcuStringMgr needs a fix in upperUtf8; added support for loading Utf8 locales (joachim)

Index: utilstr.cpp
===================================================================
RCS file: /cvs/core/sword/src/utilfuns/utilstr.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- utilstr.cpp	12 Apr 2004 11:14:30 -0000	1.27
+++ utilstr.cpp	17 Apr 2004 17:16:17 -0000	1.28
@@ -2,6 +2,9 @@
 #include <ctype.h>
 #include <string.h>
 
+#include <localemgr.h>
+
+
 #ifdef _ICU_
 #include <unicode/utypes.h>
 #include <unicode/ucnv.h>
@@ -15,6 +18,7 @@
 
 SWORD_NAMESPACE_START
 
+
 /******************************************************************************
  * stdstr - Sets/gets a string
  *
@@ -155,14 +159,19 @@
  * RET:	target
  */
 
-char *toupperstr(char *buf) {
-	char *ret = buf;
-
-	while (*buf)
-		*buf++ = SW_toupper(*buf);
-
-	return ret;
-}
+// char *toupperstr(char *buf) {
+// 	char *ret = buf;
+// 
+// 	/*if (StringHelper::getSystemStringHelper()) {
+// 		StringHelper::getSystemStringHelper()->upperStringLatin1( ret );
+// 	}
+// 	else*/ {
+// 		while (*buf) {
+// 			*buf++ = SW_toupper(*buf);
+// 		}
+// // 	}
+// 	return ret;
+// }
 
 
 /******************************************************************************
@@ -173,32 +182,37 @@
  * RET:	target
  */
 
-char *toupperstr_utf8(char *buf, unsigned int max) {
-	char *ret = buf;
-
-#ifndef _ICU_
-	// try to decide if it's worth trying to toupper.  Do we have more
-	// characters that are probably lower latin than not?
-	long performOp = 0;
-	for (const char *ch = buf; *ch; ch++)
-		performOp += (*ch > 0) ? 1 : -1;
-
-	if (performOp > 0) {
-		while (*buf)
-			*buf = SW_toupper(*buf++);
-	}
-#else
-	if (!max)
-		max = strlen(ret);
-		UErrorCode err = U_ZERO_ERROR;
-		UConverter *conv = ucnv_open("UTF-8", &err);
-		UnicodeString str(buf, -1, conv, err);
-		UnicodeString ustr = str.toUpper();
-		ustr.extract(ret, max, conv, err);
-		ucnv_close(conv);
-#endif
-
-	return ret;
-}
+// char *toupperstr_utf8(char *buf, unsigned int max) {
+// 	char *ret = buf;
+// 
+// /*	if (StringHelper::getSystemStringHelper()) {
+// 		StringHelper::getSystemStringHelper()->upperStringUtf8( ret );
+// 		return ret;
+// 	}*/
+// 	
+// #ifndef _ICU_
+// 	// try to decide if it's worth trying to toupper.  Do we have more
+// 	// characters that are probably lower latin than not?
+// 	long performOp = 0;
+// 	for (const char *ch = buf; *ch; ch++)
+// 		performOp += (*ch > 0) ? 1 : -1;
+// 
+// 	if (performOp > 0) {
+// 		while (*buf)
+// 			*buf = SW_toupper(*buf++);
+// 	}
+// #else
+// 	if (!max)
+// 		max = strlen(ret);
+// 	UErrorCode err = U_ZERO_ERROR;
+// 	UConverter *conv = ucnv_open("UTF-8", &err);
+// 	UnicodeString str(buf, -1, conv, err);
+// 	UnicodeString ustr = str.toUpper();
+// 	ustr.extract(ret, max, conv, err);
+// 	ucnv_close(conv);
+// #endif
+// 
+// 	return ret;
+// }
 
 SWORD_NAMESPACE_END