public inbox for [email protected]
help / color / mirror / Atom feedFrom: Laurenz Albe <[email protected]>
To: [email protected]
To: PostGreSQL <[email protected]>
Subject: Re: LATIN9 - hex in varchar after convert
Date: Sun, 26 Apr 2020 04:24:39 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Sat, 2020-04-25 at 10:41 +0100, Steve Tucknott (TuSol) wrote:
> I have a table with a varchar(5000) that contains general text. The table is typically
> maintained via a GUI, but on this occasion I received a spreadsheet with data and
> loaded it - via copy - from a csv extracted from that. The data looked fine in psql,
> but when looking at the data in the GUI, characters such as single quote marks (')
> appeared as a series of special characters. I assumed that the spreadsheet then had
> some different encoding (UTF8?) and that I then needed to 'translate' the characters.
Very likely, the characters were not really single quotes, but "curly quotes"
(UNICODE 201C and 201E) characters.
One of the following scenarios must have taken place:
1. The file was encoded in UTF-8, but when you copied the data in, the encoding
you specified (or had by default) was a single-gyte encoding like LATIN9.
The curly quotes are more than one byte in UTF-8, but each byte was interpreted as
a LATIN9 character.
The solution would be to specify ENCODING 'UTF8' with COPY.
2. The characters are actually fine in the database, and you loaded them correctly,
and your database client encoding is UTF8, but your terminal is in LATIN9.
The characters were displayed correctly, but your terminal interpreted each
byte as a character.
To determine which was the case, look what bytes are in the database:
SELECT badcol, badcol::bytea FROM tab WHERE id = 12345;
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: LATIN9 - hex in varchar after convert
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox