V
V
Vitaly Sivkov2014-09-09 11:41:27
PostgreSQL
Vitaly Sivkov, 2014-09-09 11:41:27

How to properly use UTF-8 in PostgreSQL?

There is a MySQL server and a local application that works with this server. Both operate on UTF-8 encoded data. Now we want to use PostgreSQL as a local data store for the application. But when you try to write data, the data is either written in crocozyabrs, or it gives the following error: "invalid byte sequence for encoding "UTF8": 0x00". I create databases in UTF-8 encoding.
PostgreSQL version - 9.3, runs on Win7.
What else could be the reason and what could be the solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Uspensky, 2014-09-11
@Kwisatz

Show the create script for the database
. It should be something like this:

CREATE DATABASE "somedb"
  WITH OWNER = "someuser"
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'Russian_Russia'
       LC_CTYPE = 'Russian_Russia'
       CONNECTION LIMIT = -1;

If it is, and the error persists, then this is a sign that your application is transmitting a SQL query not in utf-8.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question