<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
<title><![CDATA[猿来是我的巢穴]]></title>
        <image>
        <title>http://hi.baidu.com</title>
        <link>http://hi.baidu.com</link>
        <url>http://img.baidu.com/img/logo-hi.gif</url>
        </image>
<description><![CDATA[没什么]]></description>
<link>http://hi.baidu.com/kunp</link>
<language>zh-cn</language>
<generator>www.baidu.com</generator>
<ttl>5</ttl>


<item>
        <title><![CDATA[Innodb的复制发布]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/35aa6a63d49ac86a0d33fa08.html]]></link>
        <description><![CDATA[
		
		一直都没敢做Innodb的相关内容，因为一直没有对Innodb的复制发布做过研究和实验，MyIsam的复制发布相对简单，把库下面所有文件拷过去就好了。<br>
其实Innodb的做法和MyIsam类似，只不过Innodb引擎下的表的数据内容不再是存在同一的数据库目录下（MyIsam就是这么做的），Innodb引擎下，数据文件存放在ibdata1这样的文件里，而操作的log默认存放在ib_logfile0、ib_logfile1、ib_logfile2这样的文件中。<br>
几个简单的注意的地方，Innodb不能用很可能是以下的原因：<br>
1、my.cnf中有：<br>
skip-innodb<br>
请改成：<br>
#skip-innodb<br>
<br>
2、Innodb的新旧日志文件大小冲突<br>
处理办法：删除旧的日志文件<br>
<br>
<br>
所以Innodb的复制发布是以下的步骤（MyIsam的更简单一点，去掉其中特殊强调的Innodb部分，就是MyIsam的复制发布了）：<br>
1、主库上，执行FLUSH TABLES WITH READ LOCK语句清空所有表和块写入语句：（当然你也可以把数据库stop掉）<br>
mysql&gt; FLUSH TABLES WITH READ LOCK;<br>
<br>
2、得到主库当前记录点<br>
mysql &gt; SHOW MASTER STATUS;<br>
+---------------+----------+--------------+------------------+<br>
| File&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br>
+---------------+----------+--------------+------------------+<br>
| mysql-bin.003 | 73&#160;&#160;&#160;&#160;&#160;&#160; | test&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | manual,mysql&#160;&#160;&#160;&#160; |<br>
+---------------+----------+--------------+------------------+<br>
<br>
3、将主服务器的数据文件拷贝到从服务器上<br>
如果有innodb引擎，须将innodb的数据文件拷贝过来，文件名可能是ibdata1<br>
<br>
4、主库：确认文件已经生成拷贝了。<br>
mysql&gt; UNLOCK TABLES;<br>
<br>
<br>
<br>
从服务器：<br>
1.&#160;&#160;&#160; 停止用于从服务器的服务器并在其my.cnf文件中添加下面的行：<br>
[mysqld]&#160;&#160;&#160;&#160;&#160; <br>
server-id=slave_id<br>
slave_id值同Master_id值一样，必须为1到232–1之间的一个正整数值。并且，从服务器的ID必须与主服务器的ID不相同。例如：<br>
<br>
[mysqld]<br>
server-id=2<br>
<br>
2.启动从服务器<br>
<br>
3.在从服务器上设置主服务器信息<br>
mysql&gt; CHANGE MASTER TO<br>
-&gt;&#160;&#160;&#160;&#160; MASTER_HOST='master_host_name',<br>
-&gt;&#160;&#160;&#160; &#160;&#160; MASTER_PORT=3306,<br>
-&gt;&#160;&#160;&#160;&#160; MASTER_USER='replication_user_name',<br>
-&gt;&#160;&#160;&#160;&#160; MASTER_PASSWORD='replication_password',<br>
-&gt;&#160;&#160;&#160;&#160; MASTER_LOG_FILE='recorded_log_file_name',<br>
-&gt;&#160;&#160;&#160;&#160; MASTER_LOG_POS=recorded_log_position;<br>
<br>
4.启动复制<br>
mysql&gt; START SLAVE;<br>
<br>
5.查看复制状态<br>
mysql&gt; SHOW SLAVE STATUS;<br>
mysql&gt; SHOW PROCESSLIST;<br>
<br>
在Innodb的情况下：<br>
Last_Errno: 1033 <br>
此处出错是innodb的复制发布的问题，需要删除从库上原来的innodb的log文件，通常文件名为：ib_logfile0,ib_logfile1...<br>
<br>
再重新启动从库的slave。<br>
<br>
通常到这里应该就OK了，如果还有问题，需要根据show slave status\G中看到的错误代码和错误提示再进行定位了。<br>
<br>
另外从库的my.cnf中有一个设置建议用上。<br>
read_only<br>
<br>
这个属性打开很有必要，可以防止很多人为修改从库导致从库同步失败的问题。<br>
<br>
另外，再赠送两个my.cnf文件给大家。<br>
服务器配置是：<br>
4×2CPU<br>
4G内存<br>
<br>
<a href="http://docs.google.com/View?id=dg2v2gw4_58f34b9hfb" target="_blank">主库my.cnf</a><br>
<a href="http://docs.google.com/View?id=dg2v2gw4_60hcxq7md5" target="_blank">从库my.cnf</a> <a href="http://hi.baidu.com/kunp/blog/item/35aa6a63d49ac86a0d33fa08.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/it%BE%CD%CA%C7%CD%E6%BE%DF">it就是玩具</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/35aa6a63d49ac86a0d33fa08.html#comment">查看评论</a>]]></description>
        <pubDate>2009-11-11  02:58</pubDate>
        <category><![CDATA[it就是玩具]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/35aa6a63d49ac86a0d33fa08.html</guid>
</item>

<item>
        <title><![CDATA[Mysql启动中 InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes 的问题]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/84100e2445f88639c9955968.html]]></link>
        <description><![CDATA[
		
		对于使用了默认 my.cnf（一般教程都会教你使用support-files/my-medium.cnf）的Mysql服务来说<br>
如果中间使用了innodb的话，innodb默认的log file大小是56M<br>
<br>
如果你的配置文件使用了类似my-innodb-heavy-4G.cnf作为配置文件的话。<br>
Mysql可以正常启动，但innodb的表无法使用<br>
在错误日志里你会看到如下输出：<br>
<br>
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes<br>
<br>
现在需要做的事情就是把原来的 innodb 的ib_logfile×备份到一个目录下，然后删除掉原来的文件，重启 mysql。<br>
你会看到ib_logfile*大小变成了你配置文件中指定的大小。<br>
my-innodb-heavy-4G.cnf的话（log file 的大小是256M：innodb_log_file_size = 256M）<br>
你会看到很多个268435456大小的文件。<br>
<br>
<br>
附件是我推荐使用的Mysql（支持Innodb）的<a href="http://docs.google.com/Doc?docid=0AeSZSBwOThFeZGcydjJndzRfNTZkaHo4ZmNjcg&amp;hl=en" target="_blank">配置文件</a><br>
<br>
<a href="http://docs.google.com/Doc?docid=0AeSZSBwOThFeZGcydjJndzRfNTZkaHo4ZmNjcg&amp;hl=en" target="_blank">http://docs.google.com/Doc?docid=0AeSZSBwOThFeZGcydjJndzRfNTZkaHo4ZmNjcg&amp;hl=en</a> <a href="http://hi.baidu.com/kunp/blog/item/84100e2445f88639c9955968.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/%B9%A4%D7%F7%C8%D5%D6%BE%A1%AA%A1%AAlinux">工作日志——linux</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/84100e2445f88639c9955968.html#comment">查看评论</a>]]></description>
        <pubDate>2009-10-17  23:55</pubDate>
        <category><![CDATA[工作日志——linux]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/84100e2445f88639c9955968.html</guid>
</item>

<item>
        <title><![CDATA[Python MySQLdb 使用utf-8 编码插入中文数据]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/486dc2fd25dde343d7887dec.html]]></link>
        <description><![CDATA[
		
		<p>用Python的MySQLdb插入UTF-8编码的内容时经常会出问题，主要是Mysql数据库编码和python程序文档编码两个方面。本文旨在提供一个例子来解决Python插入UTF8中文数据的问题</p>
<p>使用环境：<br>
Python 2.5 for Windows<br>
MySQLdb 1.2.2 for Python 2.5<br>
MySQL 4.1.22</p>
<p>源代码如下：</p>
<p>#!/usr/bin/env python<br>
#coding=utf-8</p>
<p>import MySQLdb</p>
<p>#DB parameter<br>
strHost = '192.168.6.184'<br>
strDB = 'test'<br>
strUser = 'root'<br>
strPasswd = 'admin1111'</p>
<p>#connect to DB<br>
conn = MySQLdb.connect(host=strHost, db=strDB, user=strUser, passwd=strPasswd, charset=&quot;utf8&quot;)<br>
curs = conn.cursor()</p>
<p>curs.execute(&quot;SET NAMES utf8&quot;)<br>
curs.execute(&quot;SET CHARACTER_SET_CLIENT=utf8&quot;)<br>
curs.execute(&quot;SET CHARACTER_SET_RESULTS=utf8&quot;)<br>
conn.commit()</p>
<p>strVal = &quot;广州&quot;<br>
strSql = &quot;INSERT INTO t1( val ) values( '%s' )&quot; % strVal<br>
ret = curs.execute(strSql)<br>
conn.commit()</p>
<p><br>
curs.close()<br>
conn.close()</p> <a href="http://hi.baidu.com/kunp/blog/item/486dc2fd25dde343d7887dec.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/Code">Code</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/486dc2fd25dde343d7887dec.html#comment">查看评论</a>]]></description>
        <pubDate>2008-08-26  14:48</pubDate>
        <category><![CDATA[Code]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/486dc2fd25dde343d7887dec.html</guid>
</item>

<item>
        <title><![CDATA[boost初体验]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/1286bd3100eb89ab5fdf0e56.html]]></link>
        <description><![CDATA[
		
		知道boost很久了，一直没有时间去看，今天空下来时间，决定搞一下boost。<br>
用百度搜索了一下boost，相关的内容很少，大部分都是讲boost如何安装的。具体如何使用，涉猎的很少，不知道是会用boost的同学觉得 boost用法太简单，不需要描述，还是因为英文文档已经足够，不需要再做翻译这样的无用功。但我一向认为，中国大多数程序员，英文水平都是非常有限的， 包括我在内，看到英文文档就会头疼。<br>
这篇文章主要还是介绍如何安装boost，介绍boost的库的一些使用方法（我几乎找不到关于boost库使用的中文资料）<br>
<br>
开始前，推荐几个网址给大家，看这些网址里的东西会比我这篇文章更有效：<br>
英文好的请直接去boost的官方网站：<br>
<a target="_top" href="http://www.boost.org/">http://www.boost.org</a><br>
中文方面，直接访问<br>
<strong><a class="twikiLink" href="http://www.stlchina.org/twiki/bin/view.pl/Main/BoostChina">Boost 中文站</a><br>
<br>
<br>
</strong>言归正传，开始boost之旅吧，本文主要翻译来自 <a href="http://www.boost.org/more/getting_started.html">Boost Getting                                 Started</a> ，对其中部分内容做一点翻译和加工，英文好的同学，请直接查看该网页。<br>
<br>
<font size="5"><strong>1、获取安装包</strong></font><br>
<p class="first">最好的办法就是从 <a href="http://sourceforge.net/project/showfiles.php?group_id=7586&amp;package_id=8041" class="reference external">SourceForge</a> 下载boost安装包</p>
<ol class="arabic">
    <li>
    <p class="first">Download <a href="http://sourceforge.net/project/showfiles.php?group_id=7586&amp;package_id=8041" class="reference external"><tt class="docutils literal"><span class="pre">boost_1_34_1</span></tt><tt class="docutils literal"><span class="pre">.tar.bz2</span></tt></a>.</p>
    </li>
    <li>
    <p class="first">在你希望解压的目录下，解压安装包，执行以下命令</p>
    <pre class="literal-block">tar --bzip2 -xf <em>/path/to/</em><tt class="docutils literal"><span class="pre">boost_1_34_1</span></tt>.tar.bz2</pre>
    </li>
</ol>
<font size="5"><strong>2、BOOST目录描述（头文件的使用）</strong></font>
<p>目录结构（略）</p>
<div class="sidebar">
<p class="first sidebar-title">头文件的组织结构：</p>
<p class="pre-wrap">Boost库的头文件一般按下列规则存放:</p>
<ul class="pre-wrap last">
    <li>
    <p class="first"><tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">/ 目录下存放旧库以及小库。</span></tt>.</p>
    </li>
    <li>
    <p class="first"><tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">/</span></tt>的各个子目录存放大多数库的公共头文件， 比如, 你可以这样找到Python库的<tt class="docutils literal"><span class="pre">def.hpp</span></tt> 头文件：</p>
    <pre class="literal-block"><tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">/</span></tt><tt class="docutils literal"><span class="pre">python</span></tt><tt class="docutils literal"><span class="pre">/</span></tt><tt class="docutils literal"><span class="pre">def.hpp</span></tt>.</pre>
    </li>
    <li>
    <p class="first">一些库会在boost/目录下存放一个&ldquo;聚合头文件&rdquo;，包含该库所有的头文件。如, <a href="http://www.boost.org/libs/python/doc/building.html" class="reference external">Boost.Python</a>'的聚合头文件：</p>
    <pre class="literal-block"><tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">/</span></tt><tt class="docutils literal"><span class="pre">python.hpp</span></tt>.</pre>
    </li>
    <li>
    <p class="first">大多数库拥有私有的目录<tt class="docutils literal"><span class="pre">detail</span></tt><tt class="docutils literal"><span class="pre">/</span></tt>, 或者 <tt class="docutils literal"><span class="pre">aux_</span></tt><tt class="docutils literal"><span class="pre">/</span></tt>. 这些目录下的头文件不能被用户调用。</p>
    </li>
</ul>
所以在使用Boost的头文件的时候，程序看上去会是这个样子：<br>
#include &lt;boost/***.hpp&gt;<br>
或者<br>
#include &quot;boost/***.hpp&quot;<br>
<br>
哪种格式取决于你如何引用了。<br>
<br>
<font size="5"><strong>3、头文件就是库<br>
</strong></font>使用者最常问的问题就是&ldquo;我该怎么安装Boost&rdquo;，这个也是我一开始最关心的问题，Boost这点做的很好，将大部分实现都封装 在头文件里，所以对于一些基本的Boost库，其实是不需要安装的，只需要将头文件include到自己的程序里，当然前提是你把Boost的所有用到的 头文件都拷贝了一份。<br>
Boost是如何做到这点的？<br>
这是因为Boost的头文件（*.hpp）包含了模板和内联函数，这点随便找一个hpp文件来看你就明白了，所以不需要去静态链接活动态链接二进制lib库了。<br>
不过Boost的某些库还是需要生成二进制的库的，如果你要使用他们，必须编译安装哦，他们是：<br>
<ul class="simple">
    <li><a href="http://www.boost.org/libs/filesystem/index.html" class="reference external">Boost.Filesystem</a></li>
    <li><a href="http://www.boost.org/libs/iostreams/index.html" class="reference external">Boost.IOStreams</a></li>
    <li><a href="http://www.boost.org/libs/program_options/index.html" class="reference external">Boost.ProgramOptions</a></li>
    <li><a href="http://www.boost.org/libs/python/doc/building.html" class="reference external">Boost.Python</a> (see the <a href="http://www.boost.org/libs/python/doc/building.html" class="reference external">Boost.Python build documentation</a> before building and installing it)</li>
    <li><a href="http://www.boost.org/libs/regex/index.html" class="reference external">Boost.Regex</a></li>
    <li><a href="http://www.boost.org/libs/serialization/index.html" class="reference external">Boost.Serialization</a></li>
    <li><a href="http://www.boost.org/libs/signals/index.html" class="reference external">Boost.Signals</a></li>
    <li><a href="http://www.boost.org/doc/html/thread/build.html#thread.build" class="reference external">Boost.Thread</a></li>
    <li><a href="http://www.boost.org/libs/wave/index.html" class="reference external">Boost.Wave</a></li>
</ul>
还有一些和操作系统相关的库，太高阶了，暂时不予考虑。<br>
<br>
<font size="5"><strong>4、编写你的第一个Boost程序<br>
</strong></font>下面这个例子就是告诉你如何编写一个不需要链接boost二进制库，又能使用boost库的简单程序。<br>
test.cpp：<br>
<div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;">
<div><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"><span style="color: rgb(0, 0, 0);">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">boost</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">lambda</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">lambda.hpp</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">iostream</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">iterator</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">algorithm</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"><br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> main()<br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="width: 11px; height: 16px;"><img align="top" style="display: none;" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" ></span><span style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255); display: none;" >...</span><span ><span style="color: rgb(0, 0, 0);">{<br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);"> boost::lambda;<br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp; std::cout </span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);">Hello Boost!</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);"> std::endl;<br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="color: rgb(0, 0, 0);"><br>
<img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"></span></div>
</div>
<br>
假定boost的头文件被安装在/home/kunp/usr/local/include/boost-1_34_1<br>
执行下列语句进行编译：<br>
<br>
g++ -I /home/kunp/usr/local/include/boost-1_34_1/ test.cpp -o test<br>
<br>
<font size="5"><strong>5、使用Boost二进制库的准备</strong></font><br>
<h2>5.1、简易安装</h2>
<pre class="literal-block"><strong style="font-weight: normal;">$ cd path/to/boost_1_34_1<br>$ ./configure --help<br>这个可以帮你查看configure的参数，不过最有用的还是<br>$ ./configure --prefix=path/to/installation/prefix<br>将Boost二进制库安装到指定目录。<br>在我们这次的例子里，指定目录为/home/kun/usr/local，如果不指定目录，默认的目录会是/usr/local，这个通过看生成的Makefile，就能知道了。<br>所以我们执行以下命令：<br></strong><strong style="font-weight: normal;"><br><div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"><div><strong><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"><span style="color: rgb(0, 0, 0);">$ .</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">configure </span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">prefix</span><span style="color: rgb(0, 0, 0);">=/</span><span style="color: rgb(0, 0, 0);">home</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">kunp</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">$ make install</span></strong></div></div><br>这个需要很长时间，编译好了以后，你会看到在/home/kunp/usr/local/目录下多了lib/和include/两个子目录，其中lib/目录存放所有生成的静态和动态链接库，inclue/留了一份所有头文件的拷贝。<br><br></strong></pre>
<h2>5.2、高阶安装（指定编译器等等）</h2>
高阶的安装超过本文的范畴，直接略过。<br>
<br>
<pre class="literal-block"><font size="5"><strong>6、使用Boost二进制库</strong></font><strong style="font-weight: normal;"><br></strong>下面的程序将使用<a href="http://www.boost.org/libs/regex/index.html" class="reference external">Boost.Regex</a> 库，该库就是需要Boost独立的二进制库<br>example.cpp：<br><br><div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"><div><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"><span style="color: rgb(0, 0, 0);">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">boost</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">regex.hpp</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">iostream</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">#include </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> main()<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" ><img align="top" style="display: none;" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" ></span><span style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255); display: none;" >...</span><span ><span style="color: rgb(0, 0, 0);">{<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp; std::</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);"> line;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp; boost::regex pat( </span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);">^Subject: (Re: |Aw: )*(.*)</span><span style="color: rgb(0, 0, 0);">&quot;</span><span style="color: rgb(0, 0, 0);"> );<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> (std::cin)<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" ><img align="top" style="display: none;" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" >&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255); display: none;" >...</span><span ><span style="color: rgb(0, 0, 0);">{<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::getline(std::cin, line);<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boost::smatch matches;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (boost::regex_match(line, matches, pat))<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout </span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);"> matches[</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">&lt;&lt;</span><span style="color: rgb(0, 0, 0);"> std::endl;<br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif">&nbsp;&nbsp;&nbsp;&nbsp; }</span></span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div></div><br>使用动态库进行编译：<br><br><div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"><div><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif"><span style="color: rgb(0, 0, 0);">g</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">I </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">home</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">kunp</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 255);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">include</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">boost</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1_34_1</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"> example</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">cpp </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">o example </span><span style="color: rgb(0, 0, 0);"><br><img align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">L</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">home</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">kunp</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 255);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">lib</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">lboost_regex</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">gcc32</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">d </span></div></div><br>在我的机器上编译通过，当然，前提是你的路径写对。</pre>
<h2>6.1、Boost库的命名规则</h2>
<span>以</span><tt class="docutils literal"><span class="pre">libboost_regex-vc71-mt-d-1_34.lib</span></tt> 为例: <dl class="docutils"><dt><tt class="docutils literal"><span class="pre">lib</span></tt></dt><dd><em>Prefix</em>: 除了Microsoft Windows操作系统, 每一个Boost库都以lib为开始。在Windows下, <span>只有静态库使用</span><tt class="docutils literal"><span class="pre">lib</span></tt> 开始.</dd><dt><tt class="docutils literal"><span class="pre">boost_regex</span></tt></dt><dd><em>库名</em>: 所有Boost库都以<tt class="docutils literal"><span class="pre">boost_为库名</span></tt>.</dd><dt><tt class="docutils literal"><span class="pre">-vc71</span></tt></dt><dd><em>Toolset tag</em>: 表示编译二进制的工具的名称和版本号.</dd><dt><tt class="docutils literal"><span class="pre">-mt</span></tt></dt><dd><em>Threading tag</em>: 标明该库支持多线程。</dd><dt><tt class="docutils literal"><span class="pre">-d</span></tt></dt><dd>
<p class="first"><em>ABI tag</em>: encodes details that affect the library's interoperability with other compiled code.  For each such feature, a single letter is added to the tag:</p>
<blockquote>
<table border="1" class="docutils">
    <colgroup> <col width="6%"></col> <col width="94%"></col> </colgroup>
    <thead valign="bottom">
        <tr>
            <th class="head">Key</th>
            <th class="head">Use this library when:</th>
        </tr>
    </thead>
    <tbody valign="top">
        <tr>
            <td><tt class="docutils literal"><span class="pre">s</span></tt></td>
            <td>linking statically to the C++ standard library and compiler runtime support libraries.</td>
        </tr>
        <tr>
            <td><tt class="docutils literal"><span class="pre">g</span></tt></td>
            <td>using debug versions of the standard and runtime support libraries.</td>
        </tr>
        <tr>
            <td><tt class="docutils literal"><span class="pre">y</span></tt></td>
            <td>using a special <a href="http://www.boost.org/libs/python/doc/building.html#variants" class="reference external">debug build of Python</a>.</td>
        </tr>
        <tr>
            <td><tt class="docutils literal"><span class="pre">d</span></tt></td>
            <td>building a debug version of your code.<a href="http://www.boost.org/more/getting_started/unix-variants.html#debug-abi" class="footnote-reference"><sup>5</sup></a></td>
        </tr>
        <tr>
            <td><tt class="docutils literal"><span class="pre">p</span></tt></td>
            <td>using the STLPort standard library rather than the default one supplied with your compiler.</td>
        </tr>
        <tr>
            <td><tt class="docutils literal"><span class="pre">n</span></tt></td>
            <td>using STLPort's deprecated &ldquo;native iostreams&rdquo; feature.<a href="http://www.boost.org/more/getting_started/unix-variants.html#native" class="footnote-reference"><sup>6</sup></a></td>
        </tr>
    </tbody>
</table>
</blockquote>
<p class="last">For example, if you build a debug version of your code for use with debug versions of the static runtime library and the STLPort standard library in &ldquo;native iostreams&rdquo; mode, the tag would be: <tt class="docutils literal"><span class="pre">-sgdpn</span></tt>.  If none of the above apply, the ABI tag is ommitted.</p>
</dd><dt><tt class="docutils literal"><span class="pre">-1_34</span></tt></dt><dd><em>Version tag</em>: the full Boost release number, with periods replaced by underscores. For example, version 1.31.1 would be tagged as &quot;-1_31_1&quot;.</dd><dt><tt class="docutils literal"><span class="pre">.lib</span></tt></dt><dd><em>Extension</em>: determined according to the operating system's usual convention.  On most unix-style platforms the extensions are <tt class="docutils literal"><span class="pre">.a</span></tt> and <tt class="docutils literal"><span class="pre">.so</span></tt> for static libraries (archives) and shared libraries, respectively.  On Windows, <tt class="docutils literal"><span class="pre">.dll</span></tt> indicates a shared library and (except for static libraries built by the <tt class="docutils literal"><span class="pre">gcc</span></tt> <a href="http://www.boost.org/more/getting_started/unix-variants.html#toolset" class="reference internal">toolset</a>, whose names always end in <tt class="docutils literal"><span class="pre">.a</span></tt>) <tt class="docutils literal"><span class="pre">.lib</span></tt> indicates a static or import library.  Where supported by toolsets on unix variants, a full version extension is added (e.g. &quot;.so.1.34&quot;) and a symbolic link to the library file, named without the trailing version number, will also be created.</dd></dl> <br>
<br>
<pre class="literal-block"><br><strong style="font-weight: normal;"><br><br></strong><em><br></em> </pre>
</div> <a href="http://hi.baidu.com/kunp/blog/item/1286bd3100eb89ab5fdf0e56.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/Code">Code</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/1286bd3100eb89ab5fdf0e56.html#comment">查看评论</a>]]></description>
        <pubDate>2007-11-23  17:44</pubDate>
        <category><![CDATA[Code]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/1286bd3100eb89ab5fdf0e56.html</guid>
</item>

<item>
        <title><![CDATA[是不是给生命留下一点点纪念呢？]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/6b5d9825d9baef6335a80f56.html]]></link>
        <description><![CDATA[
		
		猿来是我：  去pica上写写你的观后感吧 <br>
猿来是我：  随便写，想到哪写到哪 <br>
猿来是我：  这样出来的文字才好 <br>
春花烂漫：  不想写 <br>
猿来是我：  写吧 <br>
猿来是我：  我觉得看完一些东西 <br>
猿来是我：  留下一些文字，是一种纪念和尊重 <br>
春花烂漫：  很奇怪啊，你想写你自己写啊，为什么还逼别人写 <br>
猿来是我：  没什么，我觉得你也可以写点东西 <br>
猿来是我：  文字和影像是可以穿越时光的 <br>
春花烂漫：  果子协附体了你 <br>
猿来是我：  我一直都这么认为 <br>
猿来是我：  和果子邪没什么关系 <br>
猿来是我：  生命的轨迹必须要有一些东西留下 <br>
春花烂漫：  但你说的和他的很像 <br>
春花烂漫：  哇，来啦 <br>
春花烂漫：  还不是附体？ <br>
猿来是我：  比如你嫂子现在留下欧猪仔的照片 <br>
春花烂漫：  我叫他留的 <br>
春花烂漫：  嘿嘿 <br>
猿来是我：  比我喜欢没事拍照 <br>
猿来是我：  不为了什么，只是为了留下时间 <br>
猿来是我：  你如果小时候写过日记 <br>
猿来是我：  10年，20年再翻看，你就会回到那段历史 <br>
猿来是我：  这些都是我自己亲身体会 <br>
猿来是我：  写不是为了给谁看，而是为了给未来的自己 <br>
春花烂漫：  我没有啊 <br>
猿来是我：  所以其实你可以写一些东西 <br>
春花烂漫：  哦～～～ <br>
猿来是我：  不为什么，只是记录生活的一个过程 <br>
猿来是我：  生命只存在于现在这一点上，过去和未来都是飘渺的，所以需要靠文字和影像来记录 <br>
春花烂漫：  哦～～～～～ <br>
猿来是我：  就好像，有时候听歌，其实不是因为那首歌的旋律或者歌者的声音 <br>
猿来是我：  只是承载了你当日的心情和故事 <br>
春花烂漫：  果子协你盗用猿来是我的号干什么？ <br>
猿来是我：  。。。 <br>
猿来是我：  算了 <br>
春花烂漫：  嘿嘿 <a href="http://hi.baidu.com/kunp/blog/item/6b5d9825d9baef6335a80f56.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/%CB%E6%B1%E3">随便</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/6b5d9825d9baef6335a80f56.html#comment">查看评论</a>]]></description>
        <pubDate>2007-11-19  10:16</pubDate>
        <category><![CDATA[随便]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/6b5d9825d9baef6335a80f56.html</guid>
</item>

<item>
        <title><![CDATA[豆瓣研究]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/09a15baf7cc8dcf8faed500a.html]]></link>
        <description><![CDATA[
		
		这篇文章只为豆瓣研究而用，持续更新<br>
<br>
豆瓣每天更新的评论（书评、影评、音乐）：600左右<br>
<br>
小组目前成为豆瓣流量最大的区域：目前共有小组44372个<br>
最大几个小组回复的流量 125+100+30+30+30+。。。 大约在500左右<br>
<br>
<br>
功能型网站，兴趣为热点的社区，无法形成生活实体。<br>
用户行为记录，用户行为分析，推荐系统优秀。 
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/it%BE%CD%CA%C7%CD%E6%BE%DF">it就是玩具</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/09a15baf7cc8dcf8faed500a.html#comment">查看评论</a>]]></description>
        <pubDate>2007-11-08  00:49</pubDate>
        <category><![CDATA[it就是玩具]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/09a15baf7cc8dcf8faed500a.html</guid>
</item>

<item>
        <title><![CDATA[惆怅开始在心里弥漫]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/35aa6a63a86a0c630c33fa91.html]]></link>
        <description><![CDATA[
		
		<p>最近我听了太多人对我吐苦水，甚至连我一向认为风云不变色的一位哥们，也在我面前倒了半天的苦水。我知道，其实他只是想找个人，听听自己的苦闷。我更了解，他夹在领导和员工中间，上下不讨好，上下失所的苦楚。</p>
<p>其实，我又何尝不是呢？</p>
<p>有时，但惆怅和无力感在胸中弥漫开来，越加浓烈的时候，也想找个人，好好倾诉一下，不需要对方太多的宽慰和理解，只需要静静的坐在那里，听你说话就好。</p>
<p>我早知道，生活不永远是阳光，工作不永远一帆风顺。有些事情，付出了努力，结果却与预计的天差地别，这种挫败感是难以承受的，更要命的是你还会失去重新证明自己的机会。</p>
<p>经常要去安慰别人，在说着那些安慰的话的时候，我常常在想，这些话真的有用吗？不知道，但做了总比不做好。每时每刻，都想面带笑容去迎接人生，but，有时候真的是强颜欢笑。</p>
<p>有段时间，想逃离，远远的躲开，现在只想着，暴风雨如果你要来，就来的更猛烈些，至少风雨之后，我有见到彩虹的希望。</p>
<p>只是，找个能听你诉苦的人，真的很难。</p> <a href="http://hi.baidu.com/kunp/blog/item/35aa6a63a86a0c630c33fa91.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/%CB%E6%B1%E3">随便</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/35aa6a63a86a0c630c33fa91.html#comment">查看评论</a>]]></description>
        <pubDate>2007-10-18  14:20</pubDate>
        <category><![CDATA[随便]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/35aa6a63a86a0c630c33fa91.html</guid>
</item>

<item>
        <title><![CDATA[我只是无聊]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/2697588293e51ca00cf4d29c.html]]></link>
        <description><![CDATA[
		
		<p>真的没骗你。</p> 
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/2697588293e51ca00cf4d29c.html#comment">查看评论</a>]]></description>
        <pubDate>2007-08-16  20:28</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/2697588293e51ca00cf4d29c.html</guid>
</item>

<item>
        <title><![CDATA[C++写的一个urlencode的例子]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/82549152b426e20f0cf3e3cd.html]]></link>
        <description><![CDATA[
		
		<p>urlencode其实是一个很简单的小玩意，在网上搜索了半天，讲如何使用的很多，讲如何实现的却很少，没办法，就自己写了一个c++的实现。希望对以后的初学者会有所帮助。</p>
<p> </p>
<p>main.cpp：</p>
<p>----------------------------------------------------------------------------------------------------------------</p>
<p>/*<br>
URLEncode是这样编码的 <br>
1。数字和字母不变。<br>
2。空格变为"+"号。<br>
3。其他被编码成"%"加上他们的ascii的十六进制，规律是这样的 <br>
比如“啊”字 Ascii的十六进制是B0A1——&gt;%B0%A1(Note:它是每个字节前加个%)。<br>
*/</p>
<p>#include &lt;iostream&gt;<br>
#include &lt;string&gt;<br>
#include &lt;fstream&gt;<br>
#include &lt;ctype.h&gt;<br>
#include &lt;stdlib.h&gt;</p>
<p>using namespace std;</p>
<p>typedef unsigned char BYTE;</p>
<p>inline BYTE toHex(const BYTE &amp;x)<br>
{<br>
 return x &gt; 9 ? x + 55: x + 48;<br>
}</p>
<p>string urlEncoding( string &amp;sIn )<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "size: " &lt;&lt; sIn.size() &lt;&lt; endl;<br>
&nbsp;&nbsp;&nbsp;&nbsp; string sOut;<br>
&nbsp;&nbsp;&nbsp;&nbsp; for( int ix = 0; ix &lt; sIn.size(); ix++ )<br>
&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BYTE buf[4];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memset( buf, 0, 4 );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( isalnum( (BYTE)sIn[ix] ) )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buf[0] = sIn[ix];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ( isspace( (BYTE)sIn[ix] ) )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buf[0] = '+';<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buf[0] = '%';<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buf[1] = toHex( (BYTE)sIn[ix] &gt;&gt; 4 );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buf[2] = toHex( (BYTE)sIn[ix] % 16);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sOut += (char *)buf;<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp; return sOut;<br>
}</p>
<p>int main(int argc, char *argv[])<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp; string src;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; ifstream inFile( "in.txt" );<br>
&nbsp;&nbsp;&nbsp;&nbsp; if( !inFile )<br>
&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "not in.txt to read" &lt;&lt; endl;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; system("PAUSE");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp; inFile &gt;&gt; src;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; string sOut = urlEncoding( src );<br>
&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; sOut &lt;&lt; endl;<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp; system("PAUSE"); <br>
&nbsp;&nbsp; return 0;<br>
}<br>
</p> <a href="http://hi.baidu.com/kunp/blog/item/82549152b426e20f0cf3e3cd.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/Code">Code</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/82549152b426e20f0cf3e3cd.html#comment">查看评论</a>]]></description>
        <pubDate>2007-05-08  20:39</pubDate>
        <category><![CDATA[Code]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/82549152b426e20f0cf3e3cd.html</guid>
</item>

<item>
        <title><![CDATA[艰难的时刻总会过去]]></title>
        <link><![CDATA[http://hi.baidu.com/kunp/blog/item/6d6e7a8970cd7ab20e244425.html]]></link>
        <description><![CDATA[
		
		<p>最近最喜欢的广告就是<u><font color="#0000ff">adidas</font></u>推出的公益广告系列。之前是阿里纳斯的“0号的故事”让我心动，有趣的是，阿里纳斯在季后赛还有几场比赛的时候，严重受伤，结束了自己这个疯狂的赛季。让人毫不惋惜。</p>
<p>然后是马晓旭的广告，看到的是一个坚强的女孩子，平平淡淡的描述，却让我看到了中国女足崛起的希望。因为马晓旭代表了80后一代中国新人的精神，如同姚明和刘翔一般，最大的共同点是，坚强，外向，我总是觉得80年后一代，便是中国崛起的希望。</p>
<p>当然最近最喜欢的一句话，却是来自贝克汉姆的广告——艰难的时刻总会过去。生活总会有很多艰难和困苦，一帆风顺永远都是一种奢望，但是请相信自己，咬紧牙，就像小贝（也可以叫老贝了）说的那样：艰难的时刻总会过去。只要，你相信你自己。</p>
<p>所以，现在每当乱七八糟的事情压在身上的时候，就会下意识地对自己说：艰难的时刻总会过去，挺住吧，哥们。</p>
<p>其实，风雨在过后，再回首，往往留下的都是美好，所以，何苦为现在而烦恼。</p> <a href="http://hi.baidu.com/kunp/blog/item/6d6e7a8970cd7ab20e244425.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/kunp/blog/category/%CB%E6%CF%EB">随想</a>&nbsp;<a href="http://hi.baidu.com/kunp/blog/item/6d6e7a8970cd7ab20e244425.html#comment">查看评论</a>]]></description>
        <pubDate>2007-04-29  00:21</pubDate>
        <category><![CDATA[随想]]></category>
        <author><![CDATA[kunp]]></author>
		<guid>http://hi.baidu.com/kunp/blog/item/6d6e7a8970cd7ab20e244425.html</guid>
</item>


</channel>
</rss>