Encoding|在freebsd中配vim和djang中文开发环境
Ok, there are a few issue with encoding:
1.vim encoding
2.console display encoding/translation
3.file encoding itself
4.encoding setting in source code like python
5.input font encoding in console: knosole in xwindow, or putty
in order to edit Chinese in an acceptable file, you need:
- A. set up the console, this could be a console in xwindow, like the program:konsole, or putty.
- in konsole, you need to setup the konsole encoding to be utf-8, so that all utf-8 encoding Chinese could be recognized.
- in putty, there are two place to setup
- appearance-font:fixedsys-GB2312 for Chinese input
- in order to see the chinese from screen, need to setup the tranlation to utf-8
- encoding - general encoding for input
- fileencoding - encoding for saving to. you can use set fileencoding=utf-8 /cp936/gb2312 to change the file encoding
- termencoding - indicate the terminal encoding, in most occations, it don't work in xwindow
- sometimes, for some program language or system, it only handle utf-8. So if you need to write a file, then it must be recognized.
- 8859 encoding is single byte encoding, so even you can type chinese and saved, it can not be read by program.
- Try to use utf-8 for file encoding,
- and also use gb2312 or cp936 for font or input encoding,
- and also setup the console to recongnize it.
- in konsole, setup the LC_CTYPE/LANG/LC_ALL=zh_CN.eucCN/zh_CN.GB2312
- special case for python: need to put #encoding=utf-8/whatever to indicate the encoding
- if
setup the LC_CTYPE/LANG/LC_ALL=zh_CN.eucCN/zh_CN.GB2312, - then you can view the chinese file name, because they are encoded as CP936
- if setup the LC_CTYPE/LANG/LC_ALL=zh_CN.UTF-8
- then the file name will be messy code
No comments:
Post a Comment