![]() Whether the SQLite CLI should anticipate bizarre translation by PowerShell's redirection mechanism (or stock cmdlet) is an open question. I have shown, per above and by other means to my own conviction, that the CLI in fact emits UTF-8 to its stdout stream when its output has been redirected (to something other than a character device, such as an open-for-write file handle or pipe.) The bottom line is that, as the OP almost said and demonstrated, output redirection in PowerShell does not play well with the SQLite shell's UTF-8 output. quit | sqlite3 utf8.sdb -cmd '.output psoc_utf8.txt' -cmd "select * from t " -cmd. Since that exploits a recent, unreleased improvement, this can be used to do the same with released SQLite CLIs:Įcho. PS> sqlite3 utf8.sdb -cmd '.output psoc_utf8.txt' -cmd "select * from t " -cmd. In Powershell, I used this workaround to get an unmolested result: (Perhaps somebody will contribute such a cmdlet, or has published one somewhere.) Unfortunately, even though there is a highly flexible "Out-File" cmdlet in PowerShell for output redirection, with a variety of encoding options, it has no such option whose proper name would be "DoNotTranslateInAnyWayShapeOrForm". The redirected file content has had plenty of "helpful" translation done to it. ![]() Let's see what the PowerShell redirected output looks like (from Bash):Ġ000000 342 224 234 342 214 220 |. The immediately preceding dumps are "correct", reflecting the DB content. % rem Dump of redirected sqlite3 query output from cmd.exe See whether aforeseen goofiness is a Windows or PowerShell issue. ![]() $ # Dump of redirected sqlite3 query output from Linux Bash: ![]() (Unsurprising since no encoding/decoding is happening.) sqlite3 utf8.sdb "select * from t " > uw_redir_utf8.txt The funky content (pasted in from clipboard) content is shown funky. $ # This will be further proven below, with a hex dump. $ # to query display to PowerShell redirector to cat to display rendering) $ # although the path (browser to clipboard to sqlite3 interactive input $ # Looks like the PS created file from an output redirect is funky, PS> # This strange reversal of "rightness" vs "wrongness" is a clue. PS> sqlite3 utf8.sdb "select * from t " > ps_redir_utf8.txt PS> # Now, see what happens with PowerShell redirect to file: PS> # The BLOB literal cast to text serves as a check on the editor output. PS> # Above ? is what we should expect from mystery clipboard transfers. Sqlite> # Show DB content on console for grins. Sqlite> # Save some output for later comparison: ![]() Sqlite> update t set tvalue=$tv_ce where tvalue='ce' Sqlite> update t set tvalue=$tv_p1 where tvalue='p1' Sqlite> update t set tvalue=cast(x'c3a9' as text) where tvalue='lc' Sqlite> create table t(tvalue text, provenance text) Sqlite> # Be sure the quoting was preserved. Sqlite> # Copy and paste e-acute from trusty utf8 editor into the "paste here": Sqlite> # Copy and paste e-acute from post #1 into the "paste here": , enter this with hand-edits where indicated: In and interactive sqlite3 session, on PowerShell: In a trust-worthy, UTF-8 conversant editor, prepare utf8_stuff.csv: It is detailed to permit replication of results and show the evidenceįor what I contend is the problem and justify the (far) below work-around. This is a long post showing how I got to the bottom of the OP's trouble. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |