PostgreSQL Client garbled problem

Source: Internet
Author: User
Tags postgresql postgresql client

Tag: encoded character pos causes reference processing error not Chinese

On the client and server-side garbled problem, the PostgreSQL character set problem Summary summary is very detailed, particularly good.

It's been a long headache for me here. The problem with the 终端 character encoding is that because the default encoding for Iterm2 on my MBP is utf-8, character garbled is actually due to Iterm2 not showing GBK encoding properly. The terminal can be displayed in Chinese, it is unclear why PO Stgresql in the shell, which leads to a problem that has never been thought of as a terminal.

About Chinese can be displayed normally, my configuration is as follows

1. 安装 PostgreSQL 的 locale 选择的是 zh_CN.UTF-82. 客户端默认编码为 utf-8, 改为 gbk (\encoding 常看当前客户端编码字符集), 有两种方式可以选择:     * set client_encoding to 'gbk'    * \encoding 'gbk'3. 终端 iterm2 字符编码设置为 'gbk'
An example of quoting citations

Assuming that the service-side code is UTF-8, the client tool PSGL defaults to GBK,

    1. Insert "Kanji" in this environment, everything is OK. At this time to the customer's "Chinese character" for GBK encoding, automatically converted to UTF-8 encoding to the server, and the query, and automatically the service side of the UTF-8 encoding to GBK to display, so there is no garbled.

    2. Set the client encoding to UTF-8, the "kanji" you just inserted is not displayed properly. Because at this time the client and the service side of the code, when fetching data without any conversion, directly the existence of the service side of the UTF8 encoded bytes to the client, then PSGL directly display, so it is garbled.

    3. This environment insert "Chinese character", then add is not successful, because "Chinese character" directly to GBK to the service side, UTF8 coding do not know, so the error. (Now the client code is UTF8, so the hint of Chinese information is garbled).

Summarize:

1. In this example, the application PSGL, without any processing of the characters entered and obtained, is displayed directly, using the same encoding method as the PG client (GBK).
2, when using as far as possible to ensure that the client code and operating system environment consistent, otherwise display and add will appear garbled situation.

PostgreSQL Client garbled problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.