SQLite Forum

null character sorts greater than 0x7f and less than 0x80
The output of the following script is <code>127 0 128</code> rather than the
expected <code>0 127 128</code>

#! /usr/bin/env tclsh
package require sqlite3
sqlite db :memory:

db eval {
    create table t (
        v text

foreach val {
} {
    string range $val 0 end
    #puts [::tcl::unsupported::representation $val]
    db eval {
        insert into t values ($val)

set sorted {}
db eval {
    select v from t order by v collate binary asc 
} {
    lappend list $v
    scan $v %c ord
    lappend sorted $ord

puts $sorted

The correct output would be <code>0 127 128</code>, woulddn't it?