Hello,
here is a patch which adds initcap function for use with icu.c (which uses
the icu4c library - International Components for Unicode).
SQL syntax for use of initcap is similar to lower or upper functions
(see documentation in the file ext/icu/README.txt.
If you need it (or like it) use it freely. Otherwise, ignore it. :)
--- patch ---
diff -Nru sqlite-3.6.7-orig/ext/icu/icu.c sqlite-3.6.7/ext/icu/icu.c
--- sqlite-3.6.7-orig/ext/icu/icu.c 2008-11-05 23:38:52.000000000 +0100
+++ sqlite-3.6.7/ext/icu/icu.c 2008-12-20 01:37:53.000000000 +0100
@@ -26,6 +26,8 @@
**
** * An implementation of the LIKE operator that uses ICU to
** provide case-independent matching.
+**
+** gcc -shared icu.c `icu-config --ldflags` -o libSqliteIcu.so
*/
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
@@ -348,7 +350,9 @@
return;
}
- if( sqlite3_user_data(p) ){
+ if( sqlite3_user_data(p) == (void*)2){
+ u_strToTitle(zOutput, nOutput/2, zInput, nInput/2, NULL, zLocale, &status);
+ }else if( sqlite3_user_data(p) == (void*)1){
u_strToUpper(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status);
}else{
u_strToLower(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status);
@@ -454,20 +458,24 @@
void *pContext; /* sqlite3_user_data() context */
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
} scalars[] = {
- {"regexp",-1, SQLITE_ANY, 0, icuRegexpFunc},
+ {"regexp", -1, SQLITE_ANY, 0, icuRegexpFunc},
- {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16},
- {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16},
- {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
- {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
-
- {"lower", 1, SQLITE_UTF8, 0, icuCaseFunc16},
- {"lower", 2, SQLITE_UTF8, 0, icuCaseFunc16},
- {"upper", 1, SQLITE_UTF8, (void*)1, icuCaseFunc16},
- {"upper", 2, SQLITE_UTF8, (void*)1, icuCaseFunc16},
+ {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16},
+ {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16},
+ {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
+ {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
+ {"initcap", 1, SQLITE_UTF16, (void*)2, icuCaseFunc16},
+ {"initcap", 2, SQLITE_UTF16, (void*)2, icuCaseFunc16},
+
+ {"lower", 1, SQLITE_UTF8, 0, icuCaseFunc16},
+ {"lower", 2, SQLITE_UTF8, 0, icuCaseFunc16},
+ {"upper", 1, SQLITE_UTF8, (void*)1, icuCaseFunc16},
+ {"upper", 2, SQLITE_UTF8, (void*)1, icuCaseFunc16},
+ {"initcap", 1, SQLITE_UTF8, (void*)2, icuCaseFunc16},
+ {"initcap", 2, SQLITE_UTF8, (void*)2, icuCaseFunc16},
- {"like", 2, SQLITE_UTF8, 0, icuLikeFunc},
- {"like", 3, SQLITE_UTF8, 0, icuLikeFunc},
+ {"like", 2, SQLITE_UTF8, 0, icuLikeFunc},
+ {"like", 3, SQLITE_UTF8, 0, icuLikeFunc},
{"icu_load_collation", 2, SQLITE_UTF8, (void*)db, icuLoadCollation},
};
--- patch ---
--
Zaga
You have worked and not worked. Not working is the hardest work of all.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users