Ryo
Ryo

Reputation: 1035

Which Postgres multi client_encoding best practice?

I have a DB server and client with encoding UTF8,and the client some time write data in SJIS or LATIN1,

ERROR:  invalid byte sequence for encoding "UTF8": 0xd5 0x78

I tried to set client_encoding to SJIS then it's worked

I wonder why this error happened?

Because I think UTF8 was support both of them descriped in this docs

https://www.postgresql.org/docs/11/multibyte.html#id-1.6.10.5.7

Are the any way to make it automatic convert without setting encoding manually?

Upvotes: 0

Views: 520

Answers (1)

Bergi
Bergi

Reputation: 664599

No, you need to explicitly tell it what encoding the client uses. Postgres does support automatic conversion between the encodings, but it does not support automatic encoding detection. If the client is assumed to use UTF-8 but then writes some SJIS bytes, they simply might end up as invalid.

Upvotes: 1

Related Questions