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,
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.
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.
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