<?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>风雪之隅 &#187; utf8</title>
	<atom:link href="http://www.laruence.com/tag/utf8/feed" rel="self" type="application/rss+xml" />
	<link>http://www.laruence.com</link>
	<description>PHP语言, PHP扩展, Zend引擎相关的研究,技术,新闻分享 - 左手代码 右手诗</description>
	<lastBuildDate>Wed, 08 Feb 2012 05:12:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>汉字和Unicode码(utf-8)之间的转换(Pack/Unpack)</title>
		<link>http://www.laruence.com/2008/05/01/106.html</link>
		<comments>http://www.laruence.com/2008/05/01/106.html#comments</comments>
		<pubDate>Thu, 01 May 2008 08:14:04 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[PHP应用]]></category>
		<category><![CDATA[pack]]></category>
		<category><![CDATA[unpack]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=106</guid>
		<description><![CDATA[保证你要转换的字符串编码为UTF8，如果不是，请iconv cnStr成utf8


<coolcode lang="php" linenum="off">
$cnStr = "中"; //utf8的中文

//unicode
$code = unpack("H6codes", $cnStr);

//汉字
$cnStr = pack("H6", $code['codes']);
</coolcode>

如果需要的是unicode的编码值, 那只要把汉字iconv成unicode再unpack就行了.

 恩, pack/unpack很强大，， 和c语言交换数据, 二进制方式的序列化,操作二进制文件.. etc...
]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2008/05/01/106.html"  title="Permanet Link to 汉字和Unicode码(utf-8)之间的转换(Pack/Unpack)" >http://www.laruence.com/2008/05/01/106.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<p>保证你要转换的字符串编码为UTF8,如果不是,请iconv cnStr成utf8</p>
<pre name="code"  class="sh_php"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
$cnStr = &quot;中&quot;; //utf8的中文

//unicode
$code = unpack(&quot;H6codes&quot;, $cnStr);

//汉字
$cnStr = pack(&quot;H6&quot;, $code['codes']);
</pre>
<p> 恩, pack/unpack很强大,, 和c语言交换数据, 二进制方式的序列化,操作二进制文件.. etc&#8230;</p>
<p> 附上format参数的说明:</p>
<pre name="code"  class="sh_bash"  linenum="off"   style="background: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:Monacobackground: #333; color: #d9d9d9; border-left: 15px solid #c9c9c9; padding: 9px; font-size: 1em; overflow-x: auto;font-family:MonacoConsolasConsolasCourierCouriermonospace;monospace;">
a 	NUL-padded string, 即&quot;\0&quot;作为&quot;空字符&quot;的表示形式
A 	SPACE-padded string, 空格作为&quot;空字符&quot;的表示形式
h 	Hex string, low nibble first,升序位顺序
H 	Hex string, high nibble first,降序位顺序
c 	signed char, 有符号单字节
C 	unsigned char, 无符号单字节
s 	signed short (always 16 bit, machine byte order)
S 	unsigned short (always 16 bit, machine byte order)
n 	unsigned short (always 16 bit, big endian byte order)
v 	unsigned short (always 16 bit, little endian byte order)
i 	signed integer (machine dependent size and byte order)
I 	unsigned integer (machine dependent size and byte order)
l 	signed long (always 32 bit, machine byte order)
L 	unsigned long (always 32 bit, machine byte order)
N 	unsigned long (always 32 bit, big endian byte order)
V 	unsigned long (always 32 bit, little endian byte order)
f 	float (machine dependent size and representation)
d 	double (machine dependent size and representation)
x 	NUL byte, 实际使用的时候作为跳过多少字节用,很有用
X 	Back up one byte, 后退1字节
@ 	NUL-fill to absolute position,实际使用的时候作为从开头跳到某字节用.
</pre>
<p><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_php.js" ></script><script type="text/javascript"  src="http://www.laruence.com/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_bash.js" ></script></p>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2008/05/01/106.html" >2008/10/17</a>, NoAngels writes: Reflection可以用来写框架的系统核心</li><li><a href="http://www.laruence.com/2008/05/01/106.html" >2011/03/20</a>, <a href="http://www.w3hacker.com/?p=245"  rel="external nofollow"  class="url" >汉字和Unicode码(utf-8)之间的转换(Pack/Unpack) | 万维网黑客联盟</a> writes: [...] 本文地址: http://www.laruence.com/2008/05/01/106.html [...]</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2007/10/03/5.html"  title="VIM中文乱码解决方案" >VIM中文乱码解决方案</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2008/05/01/106.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>VIM中文乱码解决方案</title>
		<link>http://www.laruence.com/2007/10/03/5.html</link>
		<comments>http://www.laruence.com/2007/10/03/5.html#comments</comments>
		<pubDate>Wed, 03 Oct 2007 05:11:08 +0000</pubDate>
		<dc:creator>雪候鸟</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[乱码]]></category>

		<guid isPermaLink="false">http://www.laruence.com/?p=5</guid>
		<description><![CDATA[作者: Laruence( ) 本文地址: http://www.laruence.com/2007/10/03/5.html 转载请注明出处 set langmenu=zh_CN.utf8 set fileencodings=utf-8,cp936,big5,latin1 set ambiwidth=double let $LANG=’en’ 或者也可以: set encoding=utf-8 set fileencodings=utf-8,chinese,latin-1 if has(&#8220;win32&#8243;) set fileencoding=chinese else set fileencoding=utf-8 endif &#8220;解决菜单乱码 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim &#8220;解决consle输出乱码 language messages zh_CN.utf-8 下面的方法经过我测试，是可以完美解决的，第一种没有经过测试 Comments2010/01/01, Ferro&#39;s Home &#187; Text Editor writes: [...] VIM中文乱码 set encoding=utf-8 set fileencodings=utf-8,chinese,latin-1 if has(“win32″) set [...]Copyright &#169; [...]]]></description>
			<content:encoded><![CDATA[<div class="copyright" >
<ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;">
<li>作者: <a href="http://www.laruence.com" >Laruence</a>(<a href="http://www.twitter.com/laruence"  target="meme"  title="Twitter" ><img src="/images/ico-twitter.png" /></a> <a href="http://t.sina.com/laruence"  target="meme"  title="新浪微博" ><img src="/images/ico-sina.png" /></a> <a href="http://fusion.google.com/add?feedurl=http://www.laruence.com/feed"  target="meme"  title="Google阅读器" ><img src="/images/ico-google.png" /></a> <a href="mailto:laruence@yahoo.com.cn"  target="meme"  title="邮件" ><img src="/images/ico-mail.png" /></a>)</li>
<li>本文地址: <a href="http://www.laruence.com/2007/10/03/5.html"  title="Permanet Link to VIM中文乱码解决方案" >http://www.laruence.com/2007/10/03/5.html</a></li>
</li>
<li>转载请注明出处 </li>
</ul></div>
<div id="msgcns!BDC1482E8FA76F7D!210"  class="bvMsg" >
<div>set langmenu=zh_CN.utf8<br/>
set fileencodings=utf-8,cp936,big5,latin1<br/>
set ambiwidth=double<br/>
let $LANG=’en’</div>
<div>或者也可以:</div>
<div><span style="font-family: Courier New;" >set encoding=utf-8<br/>
set fileencodings=utf-8,chinese,latin-1<br/>
if has(&#8220;win32&#8243;)<br/>
set fileencoding=chinese<br/>
else<br/>
set fileencoding=utf-8<br/>
endif<br/>
&#8220;解决菜单乱码<br/>
source $VIMRUNTIME/delmenu.vim<br/>
source $VIMRUNTIME/menu.vim<br/>
&#8220;解决consle输出乱码<br/>
language messages zh_CN.utf-8</span></div>
<div><span style="font-family: Courier New;" >下面的方法经过我测试，是可以完美解决的，第一种没有经过测试</span></div>
</div>
<hr/><h2>Comments</h2><ul  style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2007/10/03/5.html" >2010/01/01</a>, <a href="http://ferrofang.net/2010/01/01/text-editor/"  rel="external nofollow"  class="url" >Ferro&#39;s Home &raquo; Text Editor</a> writes: [...] VIM中文乱码 set encoding=utf-8 set fileencodings=utf-8,chinese,latin-1 if has(“win32″) set [...]</li></ul><hr/><small  style="font-size:85%;font-size:85%;">Copyright &copy; 2010 <a href="http://www.laruence.com"  target="_blank" >风雪之隅</a> 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)</small><h2 class="related_post_title" >Related Posts:</h2><ul class="related_post"   style="padding-left:1em;font-size:85%;padding-left:1em;font-size:85%;"><li><a href="http://www.laruence.com/2010/08/18/1718.html"  title="将PHP Manual融入(g)Vim" >将PHP Manual融入(g)Vim</a></li><li><a href="http://www.laruence.com/2010/04/17/1433.html"  title="用Vim写Blog" >用Vim写Blog</a></li><li><a href="http://www.laruence.com/2008/05/01/106.html"  title="汉字和Unicode码(utf-8)之间的转换(Pack/Unpack)" >汉字和Unicode码(utf-8)之间的转换(Pack/Unpack)</a></li><li><a href="http://www.laruence.com/2008/04/17/110.html"  title="页面乱码问题根源浅析" >页面乱码问题根源浅析</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.laruence.com/2007/10/03/5.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

