<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阿债的山寨实验室</title>
	<atom:link href="http://blog.declab.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.declab.com</link>
	<description></description>
	<lastBuildDate>Thu, 27 May 2010 03:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>最好的资源管理器扩展-QT tabbar</title>
		<link>http://blog.declab.com/software/2009/%e6%9c%80%e5%a5%bd%e7%9a%84%e8%b5%84%e6%ba%90%e7%ae%a1%e7%90%86%e5%99%a8%e6%89%a9%e5%b1%95-qt-tabbar/</link>
		<comments>http://blog.declab.com/software/2009/%e6%9c%80%e5%a5%bd%e7%9a%84%e8%b5%84%e6%ba%90%e7%ae%a1%e7%90%86%e5%99%a8%e6%89%a9%e5%b1%95-qt-tabbar/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 13:23:07 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[软件使用介绍]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=148</guid>
		<description><![CDATA[文件管理类的最有名的软件，大概是Total Commander了，但这个软件是要取代资源管理器。尽管功能强大，但每次使用的时候都要单独开一个运行窗口，这可不是我想要的（那还不如给Windows弄个Bash呢），每次我不自觉地就会打开“我的电脑”找东西。 QT tabbar好就在扩展而不是取代资源管理器。当把鼠标放在文件夹上时，会出现一个蓝色向下的小箭头，点击后会把它的所有子目录作为扩展菜单分层列出来，多方便！ 你也要试试。 No related posts. 以上关联文章由 Yet Another Related Posts Plugin 提供支持。


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>文件管理类的最有名的软件，大概是Total Commander了，但这个软件是要取代资源管理器。尽管功能强大，但每次使用的时候都要单独开一个运行窗口，这可不是我想要的（那还不如给Windows弄个Bash呢），每次我不自觉地就会打开“我的电脑”找东西。<br />
QT tabbar好就在扩展而不是取代资源管理器。当把鼠标放在文件夹上时，会出现一个蓝色向下的小箭头，点击后会把它的所有子目录作为扩展菜单分层列出来，多方便！<br />
你也要试试。</p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/software/2009/%e6%9c%80%e5%a5%bd%e7%9a%84%e8%b5%84%e6%ba%90%e7%ae%a1%e7%90%86%e5%99%a8%e6%89%a9%e5%b1%95-qt-tabbar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>地铁上想到的一个关于日期的问题</title>
		<link>http://blog.declab.com/web/2009/144/</link>
		<comments>http://blog.declab.com/web/2009/144/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 07:26:35 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[WEB开发]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=144</guid>
		<description><![CDATA[昨天在地铁上，突然想到当天是21号，星期一。打开手机看了一下，2001年1月1号正好是星期一。 于是就有一个有趣的问题：那么21世纪中(2001-2100)，每个月的1号，同时又是星期一的日子大约有多少天： A. 50 B. 150 C. 350 D. 550 当然，答案是后来设计的。当时我考虑这个问题，估计约为180左右。 这是今天用Python写的代码，运算的结果是172。 from datetime import datetime def month1st_is_monday(start=2001, end=2100): num = 0 for year in range(start, end+1): for mon in (range(1,13)): d = datetime(year, mon, 1) if (1==d.weekday()): num += 1 return num if '__main__' == __name__: print month1st_is_monday() No related posts. 以上关联文章由 Yet Another [...]


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>昨天在地铁上，突然想到当天是21号，星期一。打开手机看了一下，2001年1月1号正好是星期一。<br />
于是就有一个有趣的问题：那么21世纪中(2001-2100)，每个月的1号，同时又是星期一的日子大约有多少天：<br />
A. 50      B. 150      C. 350      D. 550<br />
当然，答案是后来设计的。当时我考虑这个问题，估计约为180左右。</p>
<p>这是今天用Python写的代码，运算的结果是172。<br />
<span id="more-144"></span></p>
<pre lang="python" line="1">
from datetime import datetime

def month1st_is_monday(start=2001, end=2100):
	num = 0
	for year in range(start, end+1):
		for mon in (range(1,13)):
			d = datetime(year, mon, 1)
			if (1==d.weekday()):
				num += 1
	return num

if '__main__' == __name__:
	print month1st_is_monday()
</pre>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/web/2009/144/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>推荐学习的函数式语言Ocaml</title>
		<link>http://blog.declab.com/web/2009/%e6%8e%a8%e8%8d%90%e5%ad%a6%e4%b9%a0%e7%9a%84%e5%87%bd%e6%95%b0%e5%bc%8f%e8%af%ad%e8%a8%80ocaml/</link>
		<comments>http://blog.declab.com/web/2009/%e6%8e%a8%e8%8d%90%e5%ad%a6%e4%b9%a0%e7%9a%84%e5%87%bd%e6%95%b0%e5%bc%8f%e8%af%ad%e8%a8%80ocaml/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 02:04:44 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[WEB开发]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=139</guid>
		<description><![CDATA[函数式的语言比较热门的有微软的F#，Erlang，Ocaml，我推荐Ocaml。 据说编译成二进制代码，有和C一样的运行高效率。这是其他两个不能比的。 这是一篇入门基础，针对面向过程(如Ｃ语言)和面向对象(如Java)的读者。 （节选自 http://www.ocaml-tutorial.org/%E5%9F%BA%E7%A1%80） 注释 OCaml的单行多行注释是用(*和*)括起，且可以使用嵌套(* &#8230; *)块。 调用函数 假设你已经写好了一个函数repeated，它的参数是一个字符串s和一个数n，返回值是把s重复n遍形成的新字符串。 在大多数源于C的语言中，调用这一函数会象下面这样: repeated (&#8220;hello&#8221;, 3) /* this is C code */ 下面是OCaml中的函数调用： repeated &#8220;hello&#8221; 3 (* this is OCaml code *) 注意：这里没有括号, 参数中间没有逗号。 我们来看另一个函数get_string_from_user，它返回从键盘读入的一个字符串。我们想把这个返回的字符串输入repeated.下面是C和OCaml的两种版本: /* C code: */ repeated (get_string_from_user (&#8220;Please type in a string.&#8221;), 3) (* OCaml code: *) repeated (get_string_from_user &#8220;Please type in [...]


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>函数式的语言比较热门的有微软的F#，Erlang，Ocaml，我推荐Ocaml。<br />
据说编译成二进制代码，有和C一样的运行高效率。这是其他两个不能比的。</p>
<p>这是一篇入门基础，针对面向过程(如Ｃ语言)和面向对象(如Java)的读者。<br />
（节选自 http://www.ocaml-tutorial.org/%E5%9F%BA%E7%A1%80）<br />
<span id="more-139"></span><br />
注释<br />
OCaml的单行多行注释是用(*和*)括起，且可以使用嵌套(* &#8230; *)块。</p>
<p>调用函数<br />
假设你已经写好了一个函数repeated，它的参数是一个字符串s和一个数n，返回值是把s重复n遍形成的新字符串。</p>
<p>在大多数源于C的语言中，调用这一函数会象下面这样:<br />
repeated (&#8220;hello&#8221;, 3)  /* this is C code */</p>
<p>下面是OCaml中的函数调用：<br />
repeated &#8220;hello&#8221; 3  (* this is OCaml code *)<br />
注意：这里没有括号, 参数中间没有逗号。</p>
<p>我们来看另一个函数get_string_from_user，它返回从键盘读入的一个字符串。我们想把这个返回的字符串输入repeated.下面是C和OCaml的两种版本:<br />
/* C code: */<br />
repeated (get_string_from_user (&#8220;Please type in a string.&#8221;), 3)</p>
<p>(* OCaml code: *)<br />
repeated (get_string_from_user &#8220;Please type in a string.&#8221;) 3<br />
请注意括号的不同和逗号的有无。一般情况下，规则是：“括号只括起整个函数调用，不要括起函数调用的参数。</p>
<p>函数定义<br />
OCaml的语法很简洁。下面是一个函数输入两个浮点数后计算它们的平均值：<br />
let average a b =<br />
  (a +. b) /. 2.0;;</p>
<p>把它输入OCaml的“toplevel”（在Unix中，在shell中输入命令ocaml）中后你会看到：<br />
# let average a b =<br />
  (a +. b) /. 2.0;;<br />
val average : float -> float -> float = <fun></p>
<p>可能大家会问：<br />
    * 为什么在OCaml中无需定义a和b的类型？OCaml怎么知道它们的类型？或者OCaml是否知道它们的类型呢?难道OCaml是完全动态类型的语言吗？<br />
    * C中2隐式转换成double类型, 可OCaml为什么不这样做？<br />
    * OCaml中return的方式是怎样?</p>
<p>我们来看答案：<br />
    * OCaml是强静态类型的语言。（也就是说没有如perl中的动态类型）。<br />
    * OCaml用类型推导（type inference）来找出类型，所以大家无需注明类型。如果你用上述OCaml的toplevel，那么OCaml会显示出它认为的函数类型。<br />
    * OCaml不做任何的隐式转换。如果你需要浮点数，你必须写2.0因为2是一个整数。<br />
    * 因为OCaml不允许操作符重载，它用不同的运算符来表示“两个整数相加”（用+）和“两个浮点数相加”（用+.）。注意后者有一个点号。其他算术运算符也是这样。<br />
    * OCaml返回函数的最后的表达式值，因此我们没有必要如C中一样写return。</p>
<p>基本类型<br />
OCaml中的基本类型是:</p>
<p>OCaml 类型      范围<br />
int            在32位处理器上是31位有符号整数(约+/- 10亿），<br />
               在64位处理器上是63位有符号整数。<br />
float          IEEE双精度浮点数，相当于C中的double。<br />
bool           布尔变量，值为true或false<br />
char           8位字符<br />
string         字符串<br />
unit           写作()</p>
<p>OCaml内部使用int中的一位来自动管理内存（垃圾收集）。因此基本 int类型是31位而非32位（如果你用64位平台，那就是63位）。但如果你的应用一定需要处理32位类型（比如你要写一些加密程序或者网络协议栈），OCaml提供nativeint类型。<br />
OCaml基本类型中没有提供无符号整数类型。但是你可以使用nativeint来达到同样效果。另外就我所知，OCaml没有单精度浮点数。<br />
OCaml提供char类型来表示字符。但可惜的是char类型不支持Unicode或者UTF-8。这是一个需要改进的很严重的缺点。但是当前我们可以使用 comprehensive Unicode libraries来处理。<br />
unit类型有点象C中的void类型。</p>
<p>隐式转换和显式转换的比较<br />
OCaml从不执行隐式转换。在OCaml中，1 + 2.5犯了类型错误。操作符+要求两个整数作为参数，而我们这里给出了一个整数一个浮点数，因此它会报错如下：</p>
<p># 1 + 2.5;;<br />
      ^^^<br />
This expression has type float but is here used with type int</p>
<p>如果我们确实需要让一个整数与一个浮点数相加该怎么办呢？（假设它们存储于变量(i和f)。在OCaml中我们需要显式转换：<br />
float_of_int i +. f;;<br />
因为从int转换到float是个特别常用的操作，float_of_int函数有个简短的别名。上面的例子可以简单地写作：<br />
float i +. f;;<br />
（注意和C不一样的是，类型和函数同名在OCaml中是完全合法的。）</p>
<p>普通函数和递归函数</p>
<p>和源于C的语言不同的是，OCaml中的函数一般不是递归的，除非你用let rec代替let来定义递归函数。下面是一个递归函数的例子：</p>
<p>let rec range a b =<br />
  if a > b then []<br />
  else a :: range (a+1) b<br />
  ;;<br />
注意这里range调用它自身。</p>
<p>多态函数</p>
<p>现在我们来看一个比较奇怪的问题。如果一个函数的参数可以是任何类型怎么办？下面就是一个奇怪的函数，它接受任何参数但总是返回3。<br />
let give_me_a_three x = 3;;</p>
<p>那么这样的函数的类型是什么呢？OCaml使用一个特殊的占位符来表示“任意类型”，这就是一个单引号后加一个字母。 上述函数的类型可以写作：<br />
give_me_a_three : &#8216;a -> int</p>
<p>这里&#8217;a表示任意类型。我们可以如give_me_a_three &#8220;foo&#8221;这样也可以象give_me_a_three 2.0这样来调用这个函数。它们都是OCaml合法的表达式。</p>
<p>类型推导<br />
简单地说：你不需要声明函数和变量的类型，因为OCaml自己会知道。<br />
而且OCaml会一直检查所有的类型匹配（甚至在不同的文件之间）。</p>
<p>我们再次来看average函数，我们在OCaml的toplevel中输入它，</p>
<p># let average a b =<br />
  (a +. b) /. 2.0;;<br />
val average : float -> float -> float = <fun></p>
<p>神奇吧？OCaml自己判断出了这个函数需要两个浮点数参数和返回一个浮点数。<br />
它是如何做到的呢？首先它看a和b在哪里使用，这里是在表达式 (a +. b)中。这里+.本身是一个需要两个浮点数参数的函数，所以通过简单推导，a和b两个都是浮点数。</p>
<p>类型推导不仅适用于短程序，也适用于大规模的程序。它是一个主要的节省时间的特性，因为它消除了一系列在其他语言中常见的造成segfault，NullPointerException和ClassCastException的错误。</p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/web/2009/%e6%8e%a8%e8%8d%90%e5%ad%a6%e4%b9%a0%e7%9a%84%e5%87%bd%e6%95%b0%e5%bc%8f%e8%af%ad%e8%a8%80ocaml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>学习英语的正确方法</title>
		<link>http://blog.declab.com/software/2009/%e5%ad%a6%e4%b9%a0%e8%8b%b1%e8%af%ad%e7%9a%84%e6%ad%a3%e7%a1%ae%e6%96%b9%e6%b3%95/</link>
		<comments>http://blog.declab.com/software/2009/%e5%ad%a6%e4%b9%a0%e8%8b%b1%e8%af%ad%e7%9a%84%e6%ad%a3%e7%a1%ae%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 03:43:20 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[软件使用介绍]]></category>
		<category><![CDATA[功夫]]></category>
		<category><![CDATA[发音]]></category>
		<category><![CDATA[正确方法]]></category>
		<category><![CDATA[英语]]></category>
		<category><![CDATA[英语学习]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=133</guid>
		<description><![CDATA[看看这个吧，提到了多数学习英语方法的误区，而且详细解释给你听，为什么这样不行？后面也提到正确方法应该是怎么样的。


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<div><object id="ssss" width="480" height="370" ><param name="allowScriptAccess" value="always" /><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://p.you.video.sina.com.cn/player/outer_player.swf?auto=1&#038;vid=23918460&#038;uid=1638817681" type="application/x-shockwave-flash" name="ssss" allowFullScreen="true" allowScriptAccess="always" width="480" height="370"></embed></object></div>
<p>看看这个吧，提到了多数学习英语方法的误区，而且详细解释给你听，为什么这样不行？后面也提到正确方法应该是怎么样的。<br />
<span id="more-133"></span><br />
龙飞虎的观点摘选如下：<br />
用你已有的英文基础去学习和连接新的英文，不要用中文系统，英文的感觉没办法用中文去解释。<br />
学外语是先听说后读写，准确发音是最重要的基础，它能促进听力。学发音要对照正确口型仔细模仿，不仅要记住发音，还要存储正确的面部肌肉感觉。<br />
语言是沟通工具，不要用分析的方法去学，当你和人沟通时，等你分析好了要讲的一句话各部分，就完全跟不上了。你要将中文和英文放在“一个盒子、两个出口”，你能很流畅地把英文从它自己的出口中倒出，才是学会了英文。</p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/software/2009/%e5%ad%a6%e4%b9%a0%e8%8b%b1%e8%af%ad%e7%9a%84%e6%ad%a3%e7%a1%ae%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode编码知识</title>
		<link>http://blog.declab.com/web/2009/unicode%e7%bc%96%e7%a0%81%e7%9f%a5%e8%af%86/</link>
		<comments>http://blog.declab.com/web/2009/unicode%e7%bc%96%e7%a0%81%e7%9f%a5%e8%af%86/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 03:17:27 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[WEB开发]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=100</guid>
		<description><![CDATA[转自 http://www.cndw.com/tech/network/2006021511561.asp UCS有两种格式：UCS-2和UCS-4。顾名思义，UCS-2就是用两个字节编码，UCS-4就是用4个字节（实际上只用了31位，最高位必须为0）编码。下面让我们做一些简单的数学游戏： UCS-2有2^16=65536个码位，UCS-4有2^31=2147483648个码位。 UCS- 4根据最高位为0的最高字节分成2^7=128个group。每个group再根据次高字节分为256个plane。每个plane根据第3个字节分为 256行 (rows)，每行包含256个cells。当然同一行的cells只是最后一个字节不同，其余都相同。 group 0的plane 0被称作Basic Multilingual Plane, 即BMP。或者说UCS-4中，高两个字节为0的码位被称作BMP。 将UCS-4的BMP去掉前面的两个零字节就得到了UCS-2。在UCS-2的两个字节前加上两个零字节，就得到了UCS-4的BMP。而目前的UCS-4规范中还没有任何字符被分配在BMP之外。 4、UTF编码 UTF-8就是以8位为单元对UCS进行编码。从UCS-2到UTF-8的编码方式如下： UCS-2编码(16进制) UTF-8 字节流(二进制) 0000 &#8211; 007F 0xxxxxxx 0080 &#8211; 07FF 110xxxxx 10xxxxxx 0800 &#8211; FFFF 1110xxxx 10xxxxxx 10xxxxxx 例如“汉”字的Unicode编码是6C49。6C49在0800-FFFF之间，所以肯定要用3字节模板了：1110xxxx 10xxxxxx 10xxxxxx。将6C49写成二进制是：0110 110001 001001， 用这个比特流依次代替模板中的x，得到：11100110 10110001 10001001，即E6 B1 89。 读者可以用记事本测试一下我们的编码是否正确。 UTF-16 以16位为单元对UCS进行编码。对于小于0&#215;10000的UCS码，UTF-16编码就等于UCS码对应的16位无符号整数。对于不小于0&#215;10000 的UCS码，定义了一个算法。不过由于实际使用的UCS2，或者UCS4的BMP必然小于0&#215;10000，所以就目前而言，可以认为UTF-16和 UCS-2基本相同。但UCS-2只是一个编码方案，UTF-16却要用于实际的传输，所以就不得不考虑字节序的问题。 5、UTF的字节序和BOM UTF- 8以字节为编码单元，没有字节序的问题。UTF-16以两个字节为编码单元，在解释一个UTF-16文本前，首先要弄清楚每个编码单元的字节序。例如收到一个“奎”的Unicode编码是594E，“乙”的Unicode编码是4E59。如果我们收到UTF-16字节流“594E”，那么这是“奎”还是 “乙”？ Unicode规范中推荐的标记字节顺序的方法是BOM。BOM不是“Bill [...]


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>转自 http://www.cndw.com/tech/network/2006021511561.asp<br />
<span id="more-100"></span><br />
UCS有两种格式：UCS-2和UCS-4。顾名思义，UCS-2就是用两个字节编码，UCS-4就是用4个字节（实际上只用了31位，最高位必须为0）编码。下面让我们做一些简单的数学游戏：</p>
<p>UCS-2有2^16=65536个码位，UCS-4有2^31=2147483648个码位。</p>
<p>UCS- 4根据最高位为0的最高字节分成2^7=128个group。每个group再根据次高字节分为256个plane。每个plane根据第3个字节分为 256行 (rows)，每行包含256个cells。当然同一行的cells只是最后一个字节不同，其余都相同。</p>
<p>group 0的plane 0被称作Basic Multilingual Plane, 即BMP。或者说UCS-4中，高两个字节为0的码位被称作BMP。</p>
<p>将UCS-4的BMP去掉前面的两个零字节就得到了UCS-2。在UCS-2的两个字节前加上两个零字节，就得到了UCS-4的BMP。而目前的UCS-4规范中还没有任何字符被分配在BMP之外。</p>
<p>4、UTF编码</p>
<p>UTF-8就是以8位为单元对UCS进行编码。从UCS-2到UTF-8的编码方式如下：</p>
<p>UCS-2编码(16进制) UTF-8 字节流(二进制)<br />
0000 &#8211; 007F 0xxxxxxx<br />
0080 &#8211; 07FF 110xxxxx 10xxxxxx<br />
0800 &#8211; FFFF 1110xxxx 10xxxxxx 10xxxxxx</p>
<p>例如“汉”字的Unicode编码是6C49。6C49在0800-FFFF之间，所以肯定要用3字节模板了：1110xxxx 10xxxxxx 10xxxxxx。将6C49写成二进制是：0110 110001 001001， 用这个比特流依次代替模板中的x，得到：11100110 10110001 10001001，即E6 B1 89。</p>
<p>读者可以用记事本测试一下我们的编码是否正确。</p>
<p>UTF-16 以16位为单元对UCS进行编码。对于小于0&#215;10000的UCS码，UTF-16编码就等于UCS码对应的16位无符号整数。对于不小于0&#215;10000 的UCS码，定义了一个算法。不过由于实际使用的UCS2，或者UCS4的BMP必然小于0&#215;10000，所以就目前而言，可以认为UTF-16和 UCS-2基本相同。但UCS-2只是一个编码方案，UTF-16却要用于实际的传输，所以就不得不考虑字节序的问题。</p>
<p>5、UTF的字节序和BOM<br />
UTF- 8以字节为编码单元，没有字节序的问题。UTF-16以两个字节为编码单元，在解释一个UTF-16文本前，首先要弄清楚每个编码单元的字节序。例如收到一个“奎”的Unicode编码是594E，“乙”的Unicode编码是4E59。如果我们收到UTF-16字节流“594E”，那么这是“奎”还是 “乙”？</p>
<p>Unicode规范中推荐的标记字节顺序的方法是BOM。BOM不是“Bill Of Material”的BOM表，而是Byte Order Mark。BOM是一个有点小聪明的想法：</p>
<p>在 UCS编码中有一个叫做&#8221;ZERO WIDTH NO-BREAK SPACE&#8221;的字符，它的编码是FEFF。而FFFE在UCS中是不存在的字符，所以不应该出现在实际传输中。UCS规范建议我们在传输字节流前，先传输字符&#8221;ZERO WIDTH NO-BREAK SPACE&#8221;。</p>
<p>这样如果接收者收到FEFF，就表明这个字节流是Big-Endian的；如果收到FFFE，就表明这个字节流是Little-Endian的。因此字符&#8221;ZERO WIDTH NO-BREAK SPACE&#8221;又被称作BOM。</p>
<p>UTF- 8不需要BOM来表明字节顺序，但可以用BOM来表明编码方式。字符&#8221;ZERO WIDTH NO-BREAK SPACE&#8221;的UTF-8编码是EF BB BF（读者可以用我们前面介绍的编码方法验证一下）。所以如果接收者收到以EF BB BF开头的字节流，就知道这是UTF-8编码了。</p>
<p>Windows就是使用BOM来标记文本文件的编码方式的。</p>
<p>6、进一步的参考资料<br />
本文主要参考的资料是 &#8220;Short overview of ISO-IEC 10646 and Unicode&#8221; (http://www.nada.kth.se/i18n/ucs/unicode-iso10646-oview.html)。</p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/web/2009/unicode%e7%bc%96%e7%a0%81%e7%9f%a5%e8%af%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下的PHP+MySQL环境安装</title>
		<link>http://blog.declab.com/server/2009/linux%e4%b8%8b%e7%9a%84phpmysql%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85/</link>
		<comments>http://blog.declab.com/server/2009/linux%e4%b8%8b%e7%9a%84phpmysql%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 09:53:49 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[服务器管理]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=85</guid>
		<description><![CDATA[首先要保证安装了pcre和gcc，make sudo pacman -S pcre sudo pacman -S gcc sudo pacman -S make 现在来安装nginx0.8.0 ./configure --prefix=/opt/nginx-0.8 --user=web --group=web \ --with-pcre --with-debug \ --with-mail --with-mail_ssl_module make &#038;&#038; make install groupadd mysql useradd mysql -G mysql ./configure --prefix=/opt/mysql-5.1 --with-mysqld-user=mysql \ --with-charset=utf8 --with-extra-charset=all \ --enable-thread-safe-client --enable-local-infile \ --with-fast-mutexes --with-low-memory --with-comment \ --with-embedded-server --without-docs --without-man /opt/mysql-5.1/bin/mysql_install_db chown -R mysql [...]


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>首先要保证安装了pcre和gcc，make<br />
<code>sudo pacman -S pcre<br />
sudo pacman -S gcc<br />
sudo pacman -S make</code></p>
<p>现在来安装nginx0.8.0<br />
<code>./configure --prefix=/opt/nginx-0.8  --user=web --group=web  \<br />
            --with-pcre  --with-debug \<br />
            --with-mail  --with-mail_ssl_module<br />
make &#038;&#038; make install<br />
</code></p>
<p><code>groupadd mysql<br />
useradd mysql -G mysql</code></p>
<pre lang="bash">
./configure --prefix=/opt/mysql-5.1 --with-mysqld-user=mysql \
            --with-charset=utf8  --with-extra-charset=all \
            --enable-thread-safe-client --enable-local-infile \
            --with-fast-mutexes  --with-low-memory  --with-comment \
            --with-embedded-server --without-docs  --without-man
</pre>
<pre lang="bash">
/opt/mysql-5.1/bin/mysql_install_db
chown -R  mysql  /opt/mysql-5.1/var
cp  /opt/mysql-5.1/share/mysql/my-small.cnf  /etc/my.cnf
ln -s /opt/mysql-5.1/bin/mysql /usr/bin/mysql
ln -s /opt/mysql-5.1/bin/mysqldump /usr/bin/mysqldump
/opt/mysql-5.1/bin/mysqld_safe --user=mysql &#038;
</pre>
<p>vi  /etc/my.cnf<br />
1) 找到 [mysqld]，在下面加入<br />
default_character_set = utf8<br />
default_table_type = innodb</p>
<p>2) 把下面10个以 #innodb开头的行，最前面的#去掉，修改后保存</p>
<pre lang="bash">
pacman -S curl  mhash  libmcrypt  libxml2  zlib  pcre libxslt
pacman -S gettext  sqlite3  openssl  gd  imagemagick mhash

libiconv

gzip -cd php-5.3.0-fpm-0.5.12-rc.diff.gz | patch -d php-5.3.0 -p1

./configure --prefix=/opt/php-5.3 --with-config-file-path=/opt/php-5.3/etc \
  --with-mysql=/opt/mysql-5.1 --with-mysqli=/opt/mysql-5.1/bin/mysql_config \
  --with-pdo-mysql --enable-sqlite-utf8 --with-db4 --enable-fpm \
  --enable-bcmath --enable-shmop --with-curl --with-curlwrappers \
  --enable-mbstring --enable-mbregex --with-mcrypt --with-gettext \
  --with-iconv-dir=/usr/local/  --with-mhash \
  --enable-safe-mode --disable-debug --disable-rpath \
  --enable-sysvsem --enable-inline-optimization \
  --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
  --with-gd --enable-gd-native-ttf --enable-zip \
  --with-pcre-dir --enable-inifile --enable-xml --enable-json --with-xsl \
  --enable-sockets --with-xmlrpc --with-ldap --with-ldap-sasl \
  --with-openssl --enable-pcntl
  --with-gnu-ld --enable-fastcgi --enable-force-cgi-redirect --enable-discard-path

EXTRA_LIBS .= '-liconv'

ulimit -SHn 51200
/opt/php-5.2/sbin/php-fpm start
/opt/nginx-0.8/sbin/nginx
</pre>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/server/2009/linux%e4%b8%8b%e7%9a%84phpmysql%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的常用Bash别名</title>
		<link>http://blog.declab.com/server/2009/%e6%88%91%e7%9a%84%e5%b8%b8%e7%94%a8bash%e5%88%ab%e5%90%8d/</link>
		<comments>http://blog.declab.com/server/2009/%e6%88%91%e7%9a%84%e5%b8%b8%e7%94%a8bash%e5%88%ab%e5%90%8d/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 07:14:25 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[服务器管理]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=96</guid>
		<description><![CDATA[vi ~/.bashrc alias ls=&#8217;ls &#8211;color=auto&#8217; alias ll=&#8217;ls -l&#8217; alias rm=&#8217;rm -i&#8217; alias df=&#8217;df -h&#8217; alias convmv-u=&#8217;convmv -f gbk -t utf-8 –notest&#8217; alias mount-u=&#8217;mount -o iocharset=utf8&#8242; alias mysqldump-u=&#8217;mysqldump -u root -p &#8211;default-character-set=utf8&#8242; No related posts. 以上关联文章由 Yet Another Related Posts Plugin 提供支持。


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>vi ~/.bashrc</p>
<p>alias ls=&#8217;ls &#8211;color=auto&#8217;<br />
alias ll=&#8217;ls -l&#8217;<br />
alias rm=&#8217;rm -i&#8217;<br />
alias df=&#8217;df -h&#8217;<br />
alias convmv-u=&#8217;convmv -f gbk -t utf-8 –notest&#8217;<br />
alias mount-u=&#8217;mount -o iocharset=utf8&#8242;<br />
alias mysqldump-u=&#8217;mysqldump -u root -p &#8211;default-character-set=utf8&#8242;</p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/server/2009/%e6%88%91%e7%9a%84%e5%b8%b8%e7%94%a8bash%e5%88%ab%e5%90%8d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal学习(1)——菜单</title>
		<link>http://blog.declab.com/web/2009/drupal%e5%ad%a6%e4%b9%a01%e2%80%94%e2%80%94%e8%8f%9c%e5%8d%95/</link>
		<comments>http://blog.declab.com/web/2009/drupal%e5%ad%a6%e4%b9%a01%e2%80%94%e2%80%94%e8%8f%9c%e5%8d%95/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 04:06:41 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[WEB开发]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[menu]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=91</guid>
		<description><![CDATA[我们打算在菜单中添加一项mymenu，我们使用的是Drupal 5.x版本。 首先，在sites/all/modules/下新建一个目录mymenu，然后在其中建两个文件mymenu.info和mymenu.module。 mymenu.info的内容比较简单，只是模块的信息，给后台管理员看的。例如： ; $Id $ name = "MyMenu Module" description = "Adds a menu to the navigation block." version = "0.01" 重点在mymenu.module文件，入口函数是mymenus_menu，相当于参数配置。 function mymenu_menu($may_cache) { // Create an array to hold the menu items we'll define. $items = array(); if ($may_cache) { // Define a static menu item. $items[] = array( //... ); [...]


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>我们打算在菜单中添加一项mymenu，我们使用的是Drupal 5.x版本。</p>
<p>首先，在sites/all/modules/下新建一个目录mymenu，然后在其中建两个文件mymenu.info和mymenu.module。<br />
<span id="more-91"></span><br />
mymenu.info的内容比较简单，只是模块的信息，给后台管理员看的。例如：<br />
<code>; $Id $<br />
name = "MyMenu Module"<br />
description = "Adds a menu to the navigation block."<br />
version = "0.01"</code></p>
<p>重点在mymenu.module文件，入口函数是mymenus_menu，相当于参数配置。</p>
<pre lang="php" line="1">
function mymenu_menu($may_cache) {
	// Create an array to hold the menu items we'll define.
	$items = array();
	if ($may_cache) {
		// Define a static menu item.
		$items[] = array(
                     //...
		);
		$items[] = array(
                     //...
		);
	}
	return $items;
}
</pre>
<p>其中菜单项$items[]的常用参数有<br />
title  (string)  标题<br />
path  (string)  URL路径，同时决定菜单的级别<br />
callback  (string)  点开URL页面时调用的函数名<br />
callback params (array)  调用函数使用的参数，可选<br />
access  (bool)  权限 一般使用 user_access(&#8216;some access tag&#8217;)的返回结果<br />
你可能需要在此文件写一个函数，类似下面，告诉权限系统用哪些tag来作为本菜单的权限标记。</p>
<pre lang="php" line="1">
function mymenu_perm() {
	return array('some access tag');
}
</pre>
<p>type  (int)  菜单的类型，有以下可选宏<br />
MENU_CUSTOM_ITEM  默认值，普通菜单<br />
MENU_CALLBACK  不显示在菜单中，但可以调用其URL<br />
MENU_LOCAL_TASK  一个页面Tab，不能是顶级菜单<br />
MENU_DEFAULT_LOCAL_TASK  默认页面Tab，不能是顶级菜单<br />
weight  (int)  同级菜单排序值</p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/web/2009/drupal%e5%ad%a6%e4%b9%a01%e2%80%94%e2%80%94%e8%8f%9c%e5%8d%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows下的Nginx+PHP+MySQL环境(续)</title>
		<link>http://blog.declab.com/server/2009/windows%e4%b8%8b%e7%9a%84nginxphpmysql%e7%8e%af%e5%a2%83%e7%bb%ad/</link>
		<comments>http://blog.declab.com/server/2009/windows%e4%b8%8b%e7%9a%84nginxphpmysql%e7%8e%af%e5%a2%83%e7%bb%ad/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 14:22:43 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[服务器管理]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[开发环境]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=78</guid>
		<description><![CDATA[今天将Nginx更新到了0.8.0，使用了官方发布的Windows版本，应该比Kevin制作Windows版稳定。 下载 opt.zip 上次的那篇日志 Windows下的Nginx+PHP+MySQL环境 No related posts. 以上关联文章由 Yet Another Related Posts Plugin 提供支持。


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>今天将Nginx更新到了0.8.0，使用了官方发布的Windows版本，应该比Kevin制作Windows版稳定。</p>
<p>下载 <a href="http://azhai.qupan.com/3638428.html">opt.zip</a></p>
<p>上次的那篇日志  <a href="http://blog.declab.com/2008/机器环境建设/windows下的nginxphpmysql环境/"> Windows下的Nginx+PHP+MySQL环境</a></p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/server/2009/windows%e4%b8%8b%e7%9a%84nginxphpmysql%e7%8e%af%e5%a2%83%e7%bb%ad/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>页面字体大小的设定</title>
		<link>http://blog.declab.com/design/2009/%e9%a1%b5%e9%9d%a2%e5%ad%97%e4%bd%93%e5%a4%a7%e5%b0%8f%e7%9a%84%e8%ae%be%e5%ae%9a/</link>
		<comments>http://blog.declab.com/design/2009/%e9%a1%b5%e9%9d%a2%e5%ad%97%e4%bd%93%e5%a4%a7%e5%b0%8f%e7%9a%84%e8%ae%be%e5%ae%9a/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 02:51:04 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[用户体验设计]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[font-size]]></category>
		<category><![CDATA[字体大小]]></category>

		<guid isPermaLink="false">http://blog.declab.com/?p=52</guid>
		<description><![CDATA[今天在ChinaUnix.net上下载了一个《无懈可击的Web设计》前四章，学到了关于设置页面字体大小最佳方法。我们知道，Firefox上的字都比IE看上去小许多。 Simplified Box Model Hack(SBMH)由Edwardson Tan发明，它用更少的、语法上更容易理解的代码实现相同的结果(能为IE5/Win和所有其他浏览器指定不同的值)。 这次我们使用SBMH，那么前面的例子就会如下所示： body { font-size: small; } * html body { font-size: x-small; /* for IE5/Win */ f\ont-size: small; /* for other IE versions */ } 首先给对象设定正常的声明，使用我们意向中的small 值。然后，使用* html选择器来利用IE中的一个bug，以提供专门用于IE 浏览器的声明。IE5/Win 会忽略font-size属性中的反斜杠，因此可以放心地为它设置x-small 值，然后，针对其他版本的IE，再用small 值将x-small值覆盖掉。 No related posts. 以上关联文章由 Yet Another Related Posts Plugin 提供支持。


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>今天在ChinaUnix.net上下载了一个《无懈可击的Web设计》前四章，学到了关于设置页面字体大小最佳方法。我们知道，Firefox上的字都比IE看上去小许多。<br />
<span id="more-52"></span></p>
<blockquote><p>
Simplified Box Model Hack(SBMH)由Edwardson Tan发明，它用更少的、语法上更容易理解的代码实现相同的结果(能为IE5/Win和所有其他浏览器指定不同的值)。<br />
这次我们使用SBMH，那么前面的例子就会如下所示：<br />
body {<br />
  font-size: small;<br />
  }<br />
* html body {<br />
  font-size: x-small; /* for IE5/Win */<br />
  f\ont-size: small; /* for other IE versions */<br />
  }<br />
首先给<body>对象设定正常的声明，使用我们意向中的small 值。然后，使用* html选择器来利用IE中的一个bug，以提供专门用于IE 浏览器的声明。IE5/Win 会忽略font-size属性中的反斜杠，因此可以放心地为它设置x-small 值，然后，针对其他版本的IE，再用small 值将x-small值覆盖掉。
</p></blockquote>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/design/2009/%e9%a1%b5%e9%9d%a2%e5%ad%97%e4%bd%93%e5%a4%a7%e5%b0%8f%e7%9a%84%e8%ae%be%e5%ae%9a/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
