Getting Python's encoding and decoding straight

Because I have recently been confusing myself with this, and because itis not clearly documented in the Python standard library or the tutorial(at least not that I could spot):

  • .decode() decodes a plain string (ie, bytes in some encoding) toa Unicode string.
  • .encode() encodes a Unicode string into a plain string.

Feeding a plain string to the unicode() constructor is the same ascalling .decode() on the string.

Things get weird if you call .encode


流感中招

so sick....

托美兒的福

(電腦主機一直壞,用鍵盤非常小的eeepc打字,常常打錯字,非常沮喪。本有長文,一直打不出來。先壓下,搞點無聊事沖喜一下吧。)

美兒大壽,與其偶像(又稱契爺)馬家輝先生吃飯,托美兒的福,輾轉終於得到傳說中的偶像
Continue reading...

How to force a crash dump on Solaris 10 x86

Because SPARCs have OpenBoot, forcing Solaris SPARC to panic and do acrash dump is generally a pretty simple process. Because x86 hardwarehas no PROM environment (despite Sun trying to pretend otherwise ), forcing a crash dump on Solaris 10 x86 is alittle bit more intricate.

Crash dumps are done through the kernel debugger, which has to be loadedahead of time from and on the system console. (Technically I think thatyou can load it on a serial connection, should you have one


當連卡佛遇上金融海嘯

當金融海嘯蓆捲全球,我的銀行存款卻反常直線上升。

沒有刻意減少消費,而是處處大減價除卻常餐加價至$32。

11月的連卡佛staff sale已減至四折,令人震驚。

早前預留了的兩對高跟鞋,埋單找數才不過$1380。

人人都說

移 民 治 水 腫


袁 彌 明 日 前 穿 上 三 點 式 泳 裝 , 大 晒 34C 、 25 和 34 的 身 材 , 其 身 形 比 早 前 纖 瘦 了 不 少 , 她 說 : 「 我 比 之 前 瘦

Continue reading...

Cripple

It was another routine morning. I went back to office, and started the computer before doing anything else. After fumbling through the keyboard, I found an Internet connection problem, and thereafter my work ground to a halt.

I couldn't open the tax computation message from the Inland Revenue Department. Interim report form for my research project could not be completed. I had no way to send out the reference letter for my intern. It was impossible for me to read the new issue of the New England Journal of

普渡慈航《波羅揭諦》(Come, Come, Come Upwards) (上)



「波羅揭諦」(Aje Aje Bara Aje) 是般若多羅蜜心經中, 不斷來回重唸的一句:「揭諦、揭諦, 波羅揭諦, 波羅僧揭諦, 菩提薩婆訶」, 意解: 「去啊, 去啊! 去到彼岸啊, 大家快去到彼岸, 趕快成就佛果」.

Sun Nyeo (姜受延) 自幼缺乏
Continue reading...

海角七號


這齣電影在台灣創下票房奇蹟
我看的時候
老是在想
台灣人為什麼不選擇楊德昌的"一一"
而是選了這一齣

" 海角七號 "其實好看
有愛情有親情有歷史情意結有社會現況
當然更重要的是這是一個關於愛與夢的故事
電影明顯受日本電

What the members of a Unicode conversion error object are

The codecs module 's register_error function has a rather scanty description of whaterror handlers are called with. Since I have just dug into this,here is what the members are for at least UnicodeDecodeError:

object The string that is being decoded to Unicode.
encoding The encoding that the string is (theoretically) in.
start The index in object of the first character that could not be decoded.
end One past the end character of this decodingproblem.
reason The human-readable error text.

The substring object