Just to make things clear, I am not on the SQLite dev team, so I have no 
influence on the documentation. I am just extrapolating from experience.

What should substr('abcd',0,-2) return? 'cd' or just 'd'? Or maybe just an 
empty string?

If you start numbering at the left with 1, 0 is just left of the string. If you 
start numbering at the right with -1, 0 is just right of the string.

Or do you take on the stance of historians: There is no year 0, there is just 
1BC immediately followed by 1AD?

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von curmudgeon
Gesendet: Montag, 26. Februar 2018 19:35
An: sqlite-users@mailinglists.sqlite.org
Betreff: [EXTERNAL] Re: [sqlite] Strange concatenation result

There's nothing special about Y=0. The Y can be anywhere outwith the string.

e.g.

substr('abc', 6, -4) = 'bc'

substr('abc', -5, 3) = 'a'

All substr functions should work this way. I wrote a c++ function to emulate it.

String substr(const String &Str, int Start, int Len) {
        if (Str=="" || !Len) return "";
        String S;
        int StrLen = Str.Length();
        if (Start < 0) Start = StrLen + Start + 1;
        if (Len < 0) {Start += Len; Len = -Len;}
        for (int i = std::max(1, Start); i <= StrLen && i < Start+Len; i++) S 
+= Str[i];
        return S;
}

// String is a windows wide string type

// I wrote it a while ago so it could probably be done gooder :-)




--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to