On 2017/12/19 10:24 PM, Tony Papadimitriou wrote:


2. Does it understand \n and \t?  I put actual line breaks inside the string >which is OK if run from script file but it won’t work with one-liners on the >command-line.>

The \n, \t, \r etc. are really dependent on some factors (OS etc.).

Yes, I know all that.  The question was if it understands them, not how they might behave depending on OS.

But that is the entire point.
SQLite doesn't handle or understand \n, \t, \r, \x, \Father Christmas....  Those things are OS-dependent escapes to get non-printable characters into command line input. SQlite calls a Line-Feed a Line-Feed. It is agnostic to  how the Line-Feed gets passed to it. The OS (sometimes) facilitates a conversion of the character sequence "\" + "n" as a "Line-Feed"  when passing it to a command-line interface, such as sqlite.exe in our case, but by the time sqlite sees it, it is already a Linefeed character (i.e. ASCII/Unicode/UTF8 Character no. 10) - sqlite doesn't know anything about "\n", it cannot, does not, and need not interpret it, it is completely irrelevant to sqlite.  "\n" is a function of the OS to allow the user to more easily send character(10) to a console application, the console application (thank goodness) need not know anything about "\n". i.e if your SQLite DOESN'T understand \n, it is a shortcoming/by design/feature of your OS, it has nothing to do with SQLite.

Is that more clear?

The same goes for UTF8.

SQLite isn't so much "ABLE" to read UTF8, as it is indeed the only way it communicates, it doesn't do non-UTF8. UTF8 is the only language it speaks. So if your UTF8 doesn't get passed correctly to SQLite it is typically a problem of the OS Code page or the sqlite-using application running in the console. (Btw. sqlite3.exe and its ilk are all command line applications and isn't the sqlite engine itself, your fixes wrt the UTF8 probably fixed the CLI in some way and it may well be a bug there, so if you can submit a test case it would be helpful - please give all the details).


So, is there any way to advance to next line from a command line printf()?

Extremely easily:
SELECT Char(10);
- or -
SELECT printf( '%s', Char(10) );

And before you ask....
Char(07) = BELL
Char(08) = BACKSPACE
Char(09) = TAB = \t
Char(10) = LF = \n
Char(11) = VTAB (Vertical Tab)
Char(12) = FF (FormFeed) - in case you print to an old-style line printer (LPT1)
Char(13) = CR = \r  (Carriage Return)
Char(27) = ESC
Char(32) = SPACE

That more or less covers the important non-printables / invisible characters.

Hope that helps :)
Ryan






Ryan

Thanks
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to