vscode-postgres
vscode-postgres copied to clipboard
Request: add ability to specify the encoding for the database
Running queries from vscode againsta database that isn't using the default (utf-8) encoding causes errors when pulling records that have special characters in them.
"invalid byte sequence for encoding: "UTF8": 0xe9 0x20 0x46
I looked for but couldn't find a way to configure the default encoding for a database for the plugin.
Do you have an easy way I can reproduce this. (maybe a sample sql script I can run to setup and see the example)?
It might be tough to do with a simple script. You'd need a database in a non-UTF8 encoding. Then you'd need to use special characters (for example non-english vowels) in the fields for that database. Let me see if I can set up an example.
Perhaps a script with a CREATE DATABASE followed by a CREATE TABLE directive with single column, followed by a single INSERT with some of the offending characters.
OK, yes, I was able to get that to work (or not work as the case might be)
-- create the database with the alternate encoding
CREATE DATABASE ascii_test
WITH
OWNER = postgres
ENCODING = 'SQL_ASCII'
LC_COLLATE = 'English_United States.1252'
LC_CTYPE = 'English_United States.1252'
TABLESPACE = pg_default
TEMPLATE = template0
CONNECTION LIMIT = -1;
-- then from within that database add some records with special characters
CREATE TABLE public.test (Place serial, Name text);
INSERT INTO public.test (Name) VALUES ('Aliança Navegaçao');
INSERT INTO public.test (Name) VALUES ('Künhe');
INSERT INTO public.test (Name) VALUES ('Jørgen');
-- Each of these records return "Invalid byte sequence" errors when queried from vscode
Thanks. I can repro with that now to figure out how best to handle it.