今天又几乎花了所有的工作时间在编辑这个来访统计网页.先是犯了些好低级的错误(关键还是没搞懂一些基本原理),把已declare的类和函数又再一遍遍的declare。然后又是懒惰(可能水平也不够)得不自己写就只在别人的代码瞎改(不过我觉得这人写得好好,格式清楚易懂,而且深得OOP的精髓,我都想把他写的小函数再另外存一遍,以后都照抄用),还瞎改的几乎都不能用。不过总算也把它给解决了。
最麻烦的还是对付baidu的搜索词。我本来还有些想谴责这个wp-slimstat的编写人不给baidu 面子,不把它列入搜索引擎的网站中,我还以为我就能轻松解决。结果却发现从baidu来的url里的搜索词全是gb2312编码(例如这个)的而不是utf-8编码 (例如google的这个),在这种全球化的年代还只守着简体中文也太爱国了吧。然后php也还没有正式的支持各种编码互换的功能,解中文码更需要些东西。 我就只能想出另一个偷懒的办法,就是把来自baidu的链接给硬新分了个版块,然后把搜索词抽取出来并保留它的gb2312编码,让浏览器去解决这个编码问题。
这时我就需要一个让浏览器知道我想它使用何种编码的命令。这个仿佛很简单,我就在html里加入了这一行:
< meta http-equiv=“Content-Type” content=“text/html; charset=GB2312″ />
可是浏览器却硬生生的忽略了我的请求,只能求助于google。 可是我却错过了google中马上能解决的方法,因为只见某人简单的一说,可以用php的header命令来发送http header。我硬是在那时错误的认为不就是html里的head那部分吗,我还不就这么干的?然后在各处瞎找,最后硬是去读了http://www.w3.org/International/tutorials/tutorial-char-enc/,才恍然记起若干年前学的一些东西,http header原来是别的东西:
真的是感觉愧对了当年的一番学习,于是匆匆的加了这个命令:
header(”Content-type: text/html; charset=$charset”);
一切就都正常的显示了:)
It has been a long time that I wanted to set up a page collecting some RSS inside and let it be the interface to our blogs. This week, finally, I started to learn the xml parser by python and actually found it very simple just to use the feedparser, which provides easy access to […]
1st year in US, what we are playing about the web is scorp’s famous Xanga (see 又开了块地 for more information), a photo album set up for our parents to view our photos (which is based on Jalbum and hosted by scorp’s Stony Brook’s webdrive back then) and the Xus’ logo with animation enabled&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;br /&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;/p&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; […]
I am not doing well to obey my own words, but not a bad solution for this moment. Next time, I am going to stick to linux totally unless Vista is so good (some excuses for later). But perfectly, I didn’t run into other linux distro this time and stayed with Fedora. Better stay […]
I couldn’t keep from myself being one of the guys bearing ant-speed ftp downloading of FC5 and experiencing this fresh out-of-oven linux suite (so hot and hard to bite for 3 days already, I bearly ended up with multimedia setup and the chinese font somewhere still causes me great trouble; though KDE is great, the […]