The problems with testing for round-trip capable codecs

In theory, testing a Python codec to see if it's round-tripcapable is pretty simple:

def willtrip(cname):   c1 = [chr(x) for x in range(0, 256)]   try:       uc = [x.decode(cname) for x in c1]       c2 = [x.encode(cname) for x in uc]   except UnicodeError:       return False   return c1 == c2

(Since it's been a while,


長尾理論與利基文化

繼續讀舊書,這次是《長尾理論》。此書 2006 年出版,但理論至今仍然適用,只因網絡平等、分散、去中心化、沒有實體限制,必然會生出長尾。長尾理論說來簡單,就是指利基 (niche) 產品在網絡平台和推薦、過濾器下,會


挑戰者

在電視螢幕看到被困地底兩個多月的智利礦工終於重見天日,心裡感恩的同時,對何謂人生挑戰者有更深刻的體會。

跟他們面對的絕境相比,失戀、失業、成績欠佳、同人鬧交、做人無目標、無錢買樓、減唔到肥,全部都是小菜

我的老朋友Canon G12

不要見我經常有新玩具試,說到買東西,我這個人,向來慢人家最少十拍。

所以,今次都可謂破例了,這部Canon G12上市還不到三天,我已經去了豐澤入手。

為什麼呢?我第一台擁有的G系是五年前的G7,後來我給了剛開始學

Continue reading...

Abortion II

Let's put the science aside, considering the current medical definition of abortion - would I advocate or not?

Well, a yes and a no.

Yes. In a social-function perspective, I support the law for legal abortion. We have entered a generation where pre-maritial sex is no longer a debate topic but a norm (I am not saying its morally right ), and in the short OG rotation I had seen at least 10 mother-to-bes who were still in their school

Congratulations to Cardinal-designate Raymond L. Burke!

During his Wednesday General Audience this morning, Pope Benedict XVI announced that then-Archbishop Raymond L. Burke, among others including then-Archbishop Wuerl of Washington, D.C., was going to be elevated to the rank of Cardinal in the Catholic Church in November!

Archbishop Raymond L. Burke

Read more about the elevation of Cardinal-designate Burke and the 2010 Consistory of Cardinals ... also, follow events from the 2010 Consistory of Cardinals live on the St. Louis Review website.

Congratulations to this


抄襲的迷惑

方舟子的網誌最近又轉載文章揭發了一個中國大陸學者抄襲論文,看來 證據確鑿 ,部份抄襲內容簡直是搬字過紙,最離譜的是連只有數十字的論文摘要也有六、七成雷同,可謂猖獗。學術抄襲的問題在大陸非常嚴重,這個現象的

Round-trip capable character encodings in Python

Suppose (mostly hypothetically) that you have some bytes in an unknownencoding (or possibly in no encoding because they represent somebinary data), but you need to pass them through some routine that onlyaccepts Unicode strings. What you need is a character encoding that canround-trip arbitrary byte values through Unicode, one that can uniquelyrepresent and reproduce all byte values from 0 to 255.

(This is not true of all character encodings. The 'ascii' codec isonly defined on some bytes,


閱讀喜劇之王 (第一部完)

第十一章 -- 適應,是演員創作的重要技巧,能夠恰當進入角色的精神生活,感受而且表現出真的反應才是演戲,但不能否認,這種能力與資質和天份是相干的︰某些人的氣質只適應某些角色性格。

第十二章 -- 類似於總結,心

20.30.40.女人

去年的10月21日,我與友人在西苑下午茶,一心享受灌湯餃這極致的人間美味,豈料,所有的專注忽然被《Face》的報導——「Speed Dating溝掂o靚醫生,30歲官恩娜超恨嫁」搶去。

然後,回家寫了 《從官恩娜到speed dating》

然後,因
Continue reading...