Edit httpd.conf.
AddType application/x-httpd-php .php .php3 .phtml
Add ".html" to that line
Restart server. ('∇'*)
2006/8/31
2006/8/30
Unicode in python2.4 under IDLE and XP SP2
先看stdin, stdout的encode是什麼
>>> sys.stdin.encoding
'cp950'
>>> sys.stdout.encoding
'cp950'
現在知道輸入時是用 cp950 來encode,把cp950的string轉成unicode的string
>>> cp= '三九あいう'
>>> cp
'\xa4T\xa4E\xc6\xa6\xc6\xa8\xc6\xaa'
>>> cp.decode('cp950')
u'\u4e09\u4e5d\u3042\u3044\u3046'
可以看到已經轉成功了,再把unicode string印出來看看
>>> uni = cp.decode('cp950')
>>> uni
u'\u4e09\u4e5d\u3042\u3044\u3046'
>>> print uni
三九あいう
ok,unicode string即使在cp950的環境下也可以正常使用,再試著轉回成cp950
>>> uni.encode('cp950')
'\xa4T\xa4E\xc6\xa6\xc6\xa8\xc6\xaa'
>>> print uni.encode('cp950')
三九あいう
看起來蠻正常的,就醬。
試著在string前加u看會如何
>>> cp = u'三九あいう'
>>> cp
u'\xa4T\xa4E\xc6\xa6\xc6\xa8\xc6\xaa'
>>> print cp
¤T¤EƦƨƪ
結果印出來的不是預期的結果,以下是測試的結果
>>> cp.decode('cp950')
Traceback (most recent call last):
File "", line 1, in -toplevel-
cp.decode('cp950')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa4' in position 0: ordinal not in range(128)
>>> cp.encode('cp950')
Traceback (most recent call last):
File "", line 1, in -toplevel-
cp.encode('cp950')
UnicodeEncodeError: 'cp950' codec can't encode character u'\xa4' in position 0: illegal multibyte sequence
>>> cp.decode('utf8')
Traceback (most recent call last):
File "", line 1, in -toplevel-
cp.decode('utf8')
File "C:\Dev\python\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa4' in position 0: ordinal not in range(128)
>>> cp.encode('utf8')
'\xc2\xa4T\xc2\xa4E\xc3\x86\xc2\xa6\xc3\x86\xc2\xa8\xc3\x86\xc2\xaa'
轉成奇怪的string
>>> print cp.encode('utf8')
¤T¤EƦƨƪ
結論是直接在非unicode的string前加u會有奇怪的結果,連結裡還講到了對file的處理以及對unicode的簡單解釋
Reference:
http://www.jorendorff.com/articles/unicode/index.html
http://evanjones.ca/python-utf8.html
>>> sys.stdin.encoding
'cp950'
>>> sys.stdout.encoding
'cp950'
現在知道輸入時是用 cp950 來encode,把cp950的string轉成unicode的string
>>> cp= '三九あいう'
>>> cp
'\xa4T\xa4E\xc6\xa6\xc6\xa8\xc6\xaa'
>>> cp.decode('cp950')
u'\u4e09\u4e5d\u3042\u3044\u3046'
可以看到已經轉成功了,再把unicode string印出來看看
>>> uni = cp.decode('cp950')
>>> uni
u'\u4e09\u4e5d\u3042\u3044\u3046'
>>> print uni
三九あいう
ok,unicode string即使在cp950的環境下也可以正常使用,再試著轉回成cp950
>>> uni.encode('cp950')
'\xa4T\xa4E\xc6\xa6\xc6\xa8\xc6\xaa'
>>> print uni.encode('cp950')
三九あいう
看起來蠻正常的,就醬。
試著在string前加u看會如何
>>> cp = u'三九あいう'
>>> cp
u'\xa4T\xa4E\xc6\xa6\xc6\xa8\xc6\xaa'
>>> print cp
¤T¤EƦƨƪ
結果印出來的不是預期的結果,以下是測試的結果
>>> cp.decode('cp950')
Traceback (most recent call last):
File "
cp.decode('cp950')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa4' in position 0: ordinal not in range(128)
>>> cp.encode('cp950')
Traceback (most recent call last):
File "
cp.encode('cp950')
UnicodeEncodeError: 'cp950' codec can't encode character u'\xa4' in position 0: illegal multibyte sequence
>>> cp.decode('utf8')
Traceback (most recent call last):
File "
cp.decode('utf8')
File "C:\Dev\python\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa4' in position 0: ordinal not in range(128)
>>> cp.encode('utf8')
'\xc2\xa4T\xc2\xa4E\xc3\x86\xc2\xa6\xc3\x86\xc2\xa8\xc3\x86\xc2\xaa'
>>> print cp.encode('utf8')
¤T¤EƦƨƪ
Reference:
http://www.jorendorff.com/articles/unicode/index.html
http://evanjones.ca/python-utf8.html
CJKPython Supported Encodings
- CJKPython
- Supported Encodings
-
- Chinese (PRC): gb2312 gbk gb18030 big5hkscs hz
- Chinese (ROC): big5 cp950
- Japanese: cp932 shift-jis shift-jisx0213 shift-jis-2004 euc-jp euc-jisx0213 euc-jis-2004 iso-2022-jp iso-2022-jp-1 iso-2022-jp-2 iso-2022-jp-3 iso-2022-jp-ext iso-2022-jp-2004
- Korean: cp949 euc-kr johab iso-2022-kr
- Unicode: utf-7 utf-8 utf-16 utf-16-be utf-16-le
2006/8/28
2006/8/27
2006/8/26
PHP query MySQL in utf8
我參考了這裡
正好解決了我的問題 ^.^v
如果說Client端是Big5,資料庫是Latin1,連線設成Latin1,
就會把Big5字串不經轉碼存到資料庫中,
如果說Client端是Big5,資料庫是Latin1,連線設成Big5,
就會把Big5字串轉碼成Latin1再存入資料庫中,
所以MySQL資料庫存入的字碼會如何是看資料庫編碼和連線編碼的,
正好解決了我的問題 ^.^v
如果說Client端是Big5,資料庫是Latin1,連線設成Latin1,
就會把Big5字串不經轉碼存到資料庫中,
如果說Client端是Big5,資料庫是Latin1,連線設成Big5,
就會把Big5字串轉碼成Latin1再存入資料庫中,
所以MySQL資料庫存入的字碼會如何是看資料庫編碼和連線編碼的,
2006/8/25
PHP document section
Note:
uses the "here document" syntax to output
multiple lines with $variable interpolation.
uses the "here document" syntax to output
multiple lines with $variable interpolation.
Note that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
2006/8/24
新竹貢丸
長久以來,我一直以為新竹貢丸真的比其他品牌的貢丸好吃很多很多。但是,這後面其實是因為一個被我忽略的因素,才有這樣的錯誤認知...
那個重要的因素就是
>>>>"湯頭"<<<<
若不是因為我媽為了滿足我弟突然想吃貢丸的念頭,而使用了高湯罐頭來,我想我是絕對不會發現的。當那鍋高湯貢丸煮好後,當我滿心期待那咬下去的瞬間能夠帶給我滿足的高潮時,一股帶著高湯罐頭味兒的肉味充滿了我的口中,那瞬間只有一種感想,
"這是新竹貢丸!!??","跟我再外面吃一碗十五元又清又淡,只灑了芹菜,就算加了胡椒也不夠味的貢丸湯竟然一模一樣!!??"
這時我才注意到原來湯的味道可以為湯中的食材加分不少,當我媽重新再用自己熬的大骨湯來煮貢丸後,那種每咬一口就有濃郁到不行、又香又甘的貢丸才又回來了。
那個重要的因素就是
>>>>"湯頭"<<<<
若不是因為我媽為了滿足我弟突然想吃貢丸的念頭,而使用了高湯罐頭來,我想我是絕對不會發現的。當那鍋高湯貢丸煮好後,當我滿心期待那咬下去的瞬間能夠帶給我滿足的高潮時,一股帶著高湯罐頭味兒的肉味充滿了我的口中,那瞬間只有一種感想,
"這是新竹貢丸!!??","跟我再外面吃一碗十五元又清又淡,只灑了芹菜,就算加了胡椒也不夠味的貢丸湯竟然一模一樣!!??"
這時我才注意到原來湯的味道可以為湯中的食材加分不少,當我媽重新再用自己熬的大骨湯來煮貢丸後,那種每咬一口就有濃郁到不行、又香又甘的貢丸才又回來了。
2006/8/12
Problem in rowspan/colspan in CSS
CSS is a presentation language. colspan and rowspan describe a
structural relationship (i.e. this cell relates to this row/col and the
next X rows/cols)
E.g:
Structure: This is a paragraph (or list, table, etc.)
Presentation: This should be this colour (font, be on the right, etc.)
from here
structural relationship (i.e. this cell relates to this row/col and the
next X rows/cols)
E.g:
Structure: This is a paragraph (or list, table, etc.)
Presentation: This should be this colour (font, be on the right, etc.)
from here
2006/8/3
Install vmtools within fc5 under xp as the host
- yum -y gcc gcc-g++ kernel-devel
- yum -y update kernel
- download vmtool's package
- reboot
- su
- ./vmtool-install.pl
- good luck
original post
訂閱:
文章 (Atom)