hoamon's sandbox
hoamon
hoamon's sandbox is about »
tag cloud
- aix
- ajax
- amazon web service
- amd64
- android
- apache
- apple
- athletes
- bank
- baseball
- bike
- bitbucket
- blog
- bond
- book
- boto
- brooks
- bullshit
- capital gains tax
- car accident
- cds
- chrome
- civil engineering
- cloud computing
- cmclass
- computer
- construction management
- construction site management
- django
- drbl
- e-sun bank
- ec2
- eclipse
- ecryptfs
- education
- election
- english
- environment
- fedora
- feeling
- finance
- firefox
- firegpg
- flash ram
- foclass
- football
- fortran
- freetds
- future
- genetic algorithm
- glassfish
- gnuplot
- google adsense
- google app engine
- google gears
- gpg
- graphviz
- gtalk
- hg
- history
- htc
- html5
- http
- https
- ibm
- iconv
- ie
- iis
- iloveit
- imagemagick
- infomation
- investment
- ipatbles
- ipp2p
- iptables
- ironman
- java
- javascript
- job
- jog
- joke
- jpg
- jquery
- jython
- kde
- knapsack problem
- latex
- learning
- least square method
- levenberg-marquardt method
- libsvm
- linux
- list
- lp
- mac
- marathon
- math
- matlab
- mencoder
- mercurial
- microsoft
- mod_fcgi
- mod_python
- modelviz
- moinmoin
- monte carlo
- movie
- mplayer
- msn
- mssql
- mysql
- netbeans
- netfilter
- newton's method
- nfl
- nginx
- odiogo
- offline system
- open source
- openid
- openoffice
- openssl
- option
- oracle
- p2p
- paypal
- pdf2jpg
- pdftojpg
- perl
- personal
- pgp
- php
- policy
- politic
- postgresql
- power
- program
- python
- python25
- r51
- rds
- realty
- reit
- restructured text
- ruby
- ruby on rails
- s3
- science
- screen
- securities
- seediq bale
- self-management
- shell script
- sis
- skype
- solaris
- something
- ssh
- ssl
- subversion
- sun
- swap
- sybase
- tax
- testcase
- the guass-newton method
- the steepest descent method
- thinkpad
- tomcat6
- tortoisehg
- totero
- trac
- travel
- triathlete
- turbogears
- ubuntu
- un*x
- unix
- vedio
- version control
- vim
- virtual machine
- virtualbox
- vst
- web
- windows
- x86_64
- yahoo
- zfs
- zipcode
- zotera
- zotero
» Trac + Mercurial on Apache 的亂碼問題
這個問題搞了我很久。
用 trac 內帶的 tracd 來跑, changelog 部份的中文就是正常的,但跑在 apache 上時,它就亂了,而且只亂 changelog 部份,程式碼的 diff 結果及 raw 格式都沒事。
看了很久的 mercurial-plugin-0.11 程式碼,看來看去覺得這應該是 mercurial 的錯,不過為什麼我在 shell 中用沒事,或是用 tracd 跑也沒問題,但它跑在 apache 上就錯了呢???
hg 在讀 changelog 的部份,它是用 mercurial.changelog.changelog 函式來處理,但裡面有一個 read() 被 mercurial-plugin 拿來用了,而這個 read 函式在解讀字串時,要叫用 util.tolocal() 來處理編碼,只要沒設定 os.environ['HGENCODING'] 的話,它就會預設為 ascii ,這就是造成 changelog 亂碼問題的地方。
以前,我只須在 /etc/python2.5/sitecustomize.py 設定 sys.setdefaultencoding('utf8') 就行了,現在還得加上 os.environ['HGENCODING'] = 'utf-8' 。
我還是不太懂 os 及 sys 的差別是什麼?







