In PHP 5.4 there will be a createCollation method to use your custom collation method, to be able to sort datasets using unicode, like this:
<?php
setlocale(LC_COLLATE, 'fr_FR.UTF-8');
$db->createCollation('PHP_COLLATE', 'strcoll');
$db->query('SELECT * FROM my_table ORDER BY name COLLATE PHP_COLLATE;');
?>
But until this cool feature becomes available, you'll have to do some tricks, like this for french:
<?php
function sqlite3_to_ascii($str, $charset = 'UTF-8')
{
if (!trim($str))
return $str;
if (preg_match('!^[[:ascii:]]+$!', $str))
return $str;
$str = htmlentities($str, ENT_NOQUOTES, $charset);
$str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str);
$str = preg_replace('#&[^;]+;#', '', $str);
return $str;
}
$db->createFunction('to_ascii', 'sqlite3_to_ascii', 1);
$res = $db->query('SELECT * FROM test ORDER BY to_ascii(text);');
?>
This will convert non-ascii characters to ascii ones before collation. In fact this won't work with non-latin languages, but for latin-languages it's better than nothing.
Please note that this will slow down about 1.8 times the query (tested on a 10.000 rows table).