- 論壇徽章:
- 1
|
本帖最后由 crykun 于 2012-04-14 18:34 編輯
萬能的cu,再次求助。
mod_python3.3.1 rhel 5.4 apache2.0.64環(huán)境,寫的psp訪問數(shù)據(jù)庫的程序,
中文字符顯示的是亂碼,刷新一次,又正常了。關(guān)閉瀏覽器,輸入網(wǎng)址,又是亂碼,刷新一次,又正常。
初步排除是數(shù)據(jù)庫字符集和meta <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
想寫一個php類似的header()改變http的報頭,不知怎么寫,可有朋友知道,這是什么原因?或是問題所在?
小弟初學(xué),高人不要笑。
下面是psp程序,一個讀取oracle記錄的演示程序:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>python oracle中文頁</title>
</head>
<body>
<%
import cx_Oracle
import os
req.write('Hello world!')
req.write('<hr>')
req.write('python oracle 中文頁')
req.write('<hr>')
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
db = cx_Oracle.connect('system', 'mz123456', '192.168.1.119/orcl')
c = db.cursor()
c.execute('SELECT id,xname FROM mytab order by id')
results = c.fetchall()
for result in results:
req.write ('%s' %result[0])
req.write (',')
req.write ('%s' %result[1])
req.write ('<br>')
db.close()
%>
</body>
</html>
|
|