3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # The focus of this file is testing of the proper handling of conversions
14 # to the native text representation.
16 # $Id: enc3.test,v 1.8 2008/01/22 01:48:09 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
24 PRAGMA encoding=utf16le;
32 INSERT INTO t1 VALUES('abc''123',5);
38 SELECT quote(x) || ' ' || quote(y) FROM t1
45 INSERT INTO t1 VALUES(x'616263646566',NULL);
51 SELECT quote(x) || ' ' || quote(y) FROM t1
53 } {{X'616263646566' NULL}}
55 ifcapable {bloblit && utf16} {
64 INSERT INTO t2 VALUES(x'61006200630064006500');
65 SELECT CAST(a AS text) FROM t2 WHERE CAST(a AS text) LIKE 'abc%';
70 SELECT CAST(x'61006200630064006500' AS text);
76 WHERE CAST(a AS text) LIKE CAST(x'610062002500' AS text);
81 # Try to attach a database with a different encoding.
83 ifcapable {utf16 && shared_cache} {
85 forcedelete test8.db test8.db-journal
86 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
87 sqlite3 dbaux test8.db
89 db eval {SELECT 1 FROM sqlite_master LIMIT 1}
92 PRAGMA encoding='utf8';
99 ATTACH 'test.db' AS utf16;
100 SELECT 1 FROM utf16.sqlite_master LIMIT 1;
102 } {1 {attached databases must use the same text encoding as main database}}
104 forcedelete test8.db test8.db-journal
105 sqlite3_enable_shared_cache $::enable_shared_cache