iT邦幫忙

0

PostgreSQL 中文出現亂碼

jeje 2012-01-13 11:54:539421 瀏覽
  • 分享至 

  • twitterImage

使用環境:Windows server 2008 ENT R2
PostgreSQL: 9.1

連接資料庫時,會出現:

C:\Users\Administrator>psql -d book -U sa
psql (9.1.1)
WARNING: Console code page (437) differs from Windows code page (950)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.
book=# select * from bookdata;
 id |      bookname       | publisher | author | publisherdate | cd
----+---------------------+-----------+--------+---------------+----
 11 | Java2 ╡{ªí│]¡pñJ¬∙  | ▓─ñT¬i    | ▒iñjªP | 2012-01-13    | t
(1 rows)
book=# \encoding
BIG5
book=#

如果我做以下的動作:

C:\Users\Administrator>chcp 950
使用中的字碼頁: 950
C:\Users\Administrator>psql -d book -U sa
psql (9.1.1)
頛詨 "help" 憿舐內隤芣???
book=# select * from bookdata;
 id |      bookname       | publisher | author | publisherdate | cd
----+---------------------+-----------+--------+---------------+----
 11 | Java2 程式設計入門  | 第三波    | 張大同 | 2012-01-13    | t
(1 蝑???)
book=# \encoding
BIG5
book=#

中文出現了,但在連接及SELECT 的部分結果還是亂碼,請各位高手幫忙如何讓整個顯事都正常,謝謝!
p.s.我設過\encoding為UTF8也沒用。。。

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
micchung
iT邦新手 3 級 ‧ 2012-01-16 16:14:08

參考 http://www.postgresql.org/docs/7.4/static/install-win32.html

雖然是舊文件,不過改 Command Prompt 下的字型看看,試著改成用其他中文字型也許會有效!?
很抱歉,我沒有用Windows所以沒辦法試,試成功的話上來報告一下吧!

jeje iT邦新手 2 級 ‧ 2012-01-18 13:31:07 檢舉

我嘗試用chcp改過了,不過還是有部分文字顯示不了中文,如原題目內容所述,謝謝!

0
foster
iT邦新手 5 級 ‧ 2012-12-26 15:33:49

先不要用chcp切語系,先用下列方法測測看,是否可以正常顯示中文
book=# set client_encoding = 'BIG5'; <---在Select先下先這行
book=# select * from bookdata;

我要發表回答

立即登入回答