I have a PostgreSQL database, which uses character encoding WIN1252
.
When querying the database, some records will produce an error when trying to read the data, because it is trying to convert it to UTF8
. This happens on some foreign names containing certain non-Latin characters.
The error is:
ERROR: 22P05: character with byte sequence 0x81 in encoding "WIN1252" has no equivalent in encoding "UTF8"
It happens when I call Read()
on the NpgsqlDataReader
.
My connection is defined as:
new NpgsqlConnection("Server=127.0.0.1;Port=5432;Database=xyz;User Id=****;Password=****;");
What can I do to read this data using C#?