0

Right now I'm running the following command from the terminal, and its giving me almost what I want.

sqlite3 file.db "SELECT colName FROM tableName;" > output.txt

Unfortunately, non-ascii characters are getting messed up. Such as dünn turning into dünn.

Is it possible to encode outputted text, like:

sqlite3 file.db "SELECT PSUDOENCODE(colName) FROM tableName;" > output.txt

And then the output would be like d#xFC;nn?

GFL
  • 1,278
  • 2
  • 15
  • 24
  • 1
    Or you could configure your client + terminal to use proper encodings. – zerkms Aug 28 '19 at 00:12
  • @zerkms, the file.db's configurations are fine, another program creates that, the only place where it could be messing up with my line that I run above. I'm down for setting the above command properly, but ultimately I'll need to convert any special characters to ascii. It would be awesome if sqlite had some type of encoding method built in. – GFL Aug 28 '19 at 00:30
  • 1
    https://stackoverflow.com/a/57047321/251311 ? – zerkms Aug 28 '19 at 00:39
  • Thank you, that was very helpful. I'm now using `HEX(colName)` and it gives me something to work with. Unfortunately, the output I'm getting is `64C3BC6E6E` with `ü` converting to `C3BC` (ü) instead of `FC`. I opened the database at the command line and ran `PRAGMA encoding;` and it outputted `UTF-8`, so its not that. And I don't think its my SSH connection messing it up since the query I now use only outputs ASCII characters. Do I need to modify my query to force UTF-8? I modified my query to `"PRAGMA encoding = 'UTF-8';SELECT HEX(colName) ..."` but that didn't change the output. – GFL Aug 28 '19 at 10:47
  • 1
    utf8 `C3BC` is `ü` that's correct. `FC` - would be invalid utf8. https://unicode-table.com/en/00FC/ – zerkms Aug 28 '19 at 11:25

0 Answers0