SQLite Forum

Unicode Input/output in sqlite3.exe on Windows 10
Login
> And what else should be done to make sqlite3.exe working with unicode?

There was a [patch][0] to enable Unicode console input and output on Windows.

[0]: https://sqlite.org/forum/forumpost/5231a77f7c

I've tested it, and I think it's well done and works quite well, but the points
mentioned in the reply (by me, when I was too lazy to register for a forum
account, I'm sorry) should be taken into account.

Related (but off-topic):

Calling directly into `ReadConsoleW()` (instead of `fgets()` provided by the
CRT) has the advantage that it's possible to intercept Ctrl-C, i.e. the function
returns `TRUE` but sets `*lpNumberOfCharsRead` to `0`, and `GetLastError()`
returns `ERROR_OPERATION_ABORTED`. (In practice, because other error conditions
are unlikely, this is probably the same as `fgets()` returning an empty string,
but the latter does some special processing, for example for Ctrl-Z.)

So something based on the linked patch could even be used to disarm the strict
handling of Ctrl-C on Windows a bit, i.e. disable the global handler set by
`SetConsoleCtrlHandler()` when calling `ReadConsoleW()`. Because I commonly end
up terminating the shell when I meant to cancel input to the current line (or
some multi-line statement, when there's a typo in the no-longer-editable
previous line, and I want to start over instead of completing the statement), or
when I meant to cancel an SQL command being executed that completes moments
before I was able to reach Ctrl-C.

(Not sure if the sharp Ctrl-C handling is what people are used to on other
platforms, but it seems that at least using Ctrl-C to cancel a partially input
line without terminating the shell is not only a Windows thing.)