I am developing a SQLite DB on Android with text containing UTF8. Known problem in SQLite is the missing of case insensitive non-ASCII (UTF8) functions for sorting and LIKE comparison.
In the SQL library is there a way to impement a UDF with sqlite3_create_function?
What I usually implement in PHP is solution / implementation (thanks to blog.amartynov.ru) which works:
function lexa_ci_utf8_like($mask, $value) {
$mask = str_replace(
array("%", "_"),
array(".*?", "."),
preg_quote($mask, "/")
);
$mask = "/^$mask$/ui";
return preg_match($mask, $value);
}
$pdo->sqliteCreateFunction('like', "lexa_ci_utf8_like", 2);
In the SQL library is there a way to impement a UDF with sqlite3_create_function?
What I usually implement in PHP is solution / implementation (thanks to blog.amartynov.ru) which works:
function lexa_ci_utf8_like($mask, $value) {
$mask = str_replace(
array("%", "_"),
array(".*?", "."),
preg_quote($mask, "/")
);
$mask = "/^$mask$/ui";
return preg_match($mask, $value);
}
$pdo->sqliteCreateFunction('like', "lexa_ci_utf8_like", 2);