sqlite3_unicode updated for SQLite3 v3.6.7

Since v3.6.1, SQLite3 amalgamation package includes the ICU (International Components for Unicode) source code to make it easier to build SDLite3 with the ICU extension enabled, see [check-in].

This change has broken sqlite3_unicode source code and could no longer be automatically loaded by hijacking the ICU start-up function. For this reason sqlite3_unicode has been updated (to build 10) which is fully compatible with SQLite v3.6.7, but must be manually loaded using custom exported functions, which are defined in a separate sqlite3_unicode.h header file, and explained below.

This version has been tested to build under Microsoft Windows and Ubuntu 8.10 Intrepid and work flawlessly either as a static or shared library.

A bug was fixed in the NOCASE collation source that prevented proper sorting of UTF-8 encoded strings.
NOCASE collation now works for both UTF-8 and UTF-16 encoded strings, but unlike ICU it does not take into account any language specific sorting logarithms.

To activate unicode functionality the following function must be called during application initialization sequence: sqlite3_unicode_load();
The function does not take any arguments and simply calls sqlite3_auto_extension(); function to load the extension.

Similarly before application exit the following function must be called to cleanup memory and unload extension: sqlite3_unicode_free();
The function does not take any arguments and simply calls sqlite3_reset_auto_extension(); function to unload the extension.

The library has been thouroughly tested for Greek language through a small greek-english dictionary project, designed to test:

  1. the case folding conversion,
  2. the LIKE operation in a SELECT statement, and
  3. the NOCASE collation (using case folding and unaccenting of greek strings to enable proper sorting).

Download the implementation file sqlite3_unicode.c

Last Modified: Sunday, January 11th, 2009 @ 20:29

This entry was posted on Sunday, January 11th, 2009 at 8:23 pm and is filed under Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 Responses to “sqlite3_unicode updated for SQLite3 v3.6.7”

  1. Markus Gritsch said on

    I would like to include this into my custom built of pysqlite (Python bindings for SQLite).  Do you have any advice how to accomplish this?  The build uses the amalgamation.c and .h files.  When I add the sqlite3_unicode.c and .h files beside the amalgamation files and add sqlite3_unicode.c to the source files, I get the following error

    amalgamation\sqlite3_unicode.c(81) : fatal error C1083: Cannot open include file: ‘sqlite3ext.h’: No such file or directory

    I use the defiles SQLITE_CORE and SQLITE_ENABLE_ICU

  2. Markus Gritsch said on

    Markus Gritsch said on June 3, 2009 at 2:30 pm
    C1083: Cannot open include file: ‘sqlite3ext.h’: No such file or directory I use the defiles SQLITE_CORE and SQLITE_ENABLE_ICU

    I finally managed to get it working!  The automated download process for building pysqlite does omit the sqlite3ext.h file.  I downloaded the amalgamation package manually and put the missing sqlite3ext.h file beside the other files, and the compilation process went well )

    Thank you so much for providing such a great library.

  3. Markus Gritsch said on

    The following statements work:
    SELECT ‘Ä’ LIKE ‘ä’
    -> 1
    SELECT UNACCENT(‘Ä’)
    -> A

    However, the LOWER and UPPER functions do not seem to work:
    SELECT LOWER(‘Ä’)
    -> Ä
    SELECT UPPER(‘ä’)
    -> ä

    Do these functions behave correctly for you?

  4. Thank you Ioannis! I blogged a little article on how to get this to run on the iPhone (and therefore Mac OS X as well).
    Hmmm, this gets rejected as spam when I enter the link in the “Website:” field. Try again: http://pp.hillrippers.ch/blog/2009/08/08/Static+SQLite+Library+with+Unicode+Support+for+the+iPhone/

  5. May I take a part of your trusty page to my blogs

  6. The first time that i tried overcloking over a year ago, my CPU got overheated and got fried.*;-

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">