<?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>闫鹏 blog &#187; 编码</title>
	<atom:link href="http://www.mirecle.com/tag/%e7%bc%96%e7%a0%81/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mirecle.com</link>
	<description>it,技术,经济生活,互联网</description>
	<lastBuildDate>Thu, 29 Jul 2010 08:50:28 +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>关于网页/javascript的中文乱码</title>
		<link>http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html</link>
		<comments>http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html#comments</comments>
		<pubDate>Tue, 19 Jan 2010 05:04:03 +0000</pubDate>
		<dc:creator>闫鹏</dc:creator>
				<category><![CDATA[程序员]]></category>
		<category><![CDATA[编码]]></category>

		<guid isPermaLink="false">http://www.mirecle.com/?p=96040</guid>
		<description><![CDATA[关于网页乱码问题，网上貌似有不少的说法，但与此同时，也有很多人说解决方法不起作用，无论是在网页的head头中加上“”标识还是修改apache的AddDefaultCharset问题，都有不能解决问题的时候。其实大家把这个搞复杂了，影响正常显示的只有两个因素： 1.网页被浏览器解码的方式 2.网页文件中字符本身的编码方式 只要这两个是一致的，就可以解决乱码问题。JavaScript操作中文出现乱码的问题和这个也是同一个道理。 在网页的head头上制定charset是要求浏览器按照制定的方式对这个页面进行解码，而在apache配置AddDefaultCharset则是在response的一个header中加上了指定的解码方式。个人感觉还是在head头中指定更灵活一些，当然，这个是与应用相关的，孰优孰劣也说不定。 解决了浏览器解码的问题，就需要注意查看文件的编码是否与指定的解码方式是否一致，在vim里面可以通过&#8221;set encoding&#8221;来查看当前文件的编码方式，使用&#8221;set encoding=gbk&#8221;就可以指定文件的编码方式是gbk了。我目前用的文件编码方式多是latin1的，貌似反而到没有遇到乱码的问题，具体没有进行深究 编码方式，还是推荐大家使用gbk或者gb18030。gbk(gb13000)中包含： 1.gb2312的全部汉字，非汉字的符号 2.big5中的全部汉字 3.其它 CJK 汉字 4.其它汉字，部首，符号 gb18030是在2000年推出的标准，与gbk完全兼容 本文永久链接:http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html [发表评论] 您可能会喜欢:php中set names与mysql_set_charset


您可能会喜欢:<ol><li><a href='http://www.mirecle.com/2010/04/13/php-in-the-set-names-and-mysql_set_charset.html' rel='bookmark' title='Permanent Link: php中set names与mysql_set_charset'>php中set names与mysql_set_charset</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--adv-->
<img src="http://emoneycreater.appspot.com/jd.jpg" width="0" height="0"/>
<img src="http://emoneycreater.appspot.com/sn.jpg" width="0" height="0"/>
<img src="http://emoneycreater.appspot.com/img01.tianya.cn.dehm.jpg" width="0" height="0"/>
<!--adv end-->
<p>关于网页乱码问题，网上貌似有不少的说法，但与此同时，也有很多人说解决方法不起作用，无论是在网页的head头中加上“<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>”标识还是修改apache的AddDefaultCharset问题，都有不能解决问题的时候。其实大家把这个搞复杂了，影响正常显示的只有两个因素：</p>
<blockquote><p>1.网页被浏览器解码的方式</p>
<p>2.网页文件中字符本身的编码方式</p>
</blockquote>
<p>只要这两个是一致的，就可以解决乱码问题。JavaScript操作中文出现乱码的问题和这个也是同一个道理。</p>
<p>在网页的head头上制定charset是要求浏览器按照制定的方式对这个页面进行解码，而在apache配置AddDefaultCharset则是在response的一个header中加上了指定的解码方式。个人感觉还是在head头中指定更灵活一些，当然，这个是与应用相关的，孰优孰劣也说不定。</p>
<p>解决了浏览器解码的问题，就需要注意查看文件的编码是否与指定的解码方式是否一致，在vim里面可以通过&#8221;set encoding&#8221;来查看当前文件的编码方式，使用&#8221;set encoding=gbk&#8221;就可以指定文件的编码方式是gbk了。我目前用的文件编码方式多是latin1的，貌似反而到没有遇到乱码的问题，具体没有进行深究</p>
<p>编码方式，还是推荐大家使用gbk或者gb18030。gbk(gb13000)中包含：<br />
1.gb2312的全部汉字，非汉字的符号<br />
2.big5中的全部汉字<br />
3.其它 CJK 汉字<br />
4.其它汉字，部首，符号<br />
gb18030是在2000年推出的标准，与gbk完全兼容</p>
本文永久链接:<a href="http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html">http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html</a>
<br/>
[<a href="http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html#respond">发表评论</a>]

<p>您可能会喜欢:<ol><li><a href='http://www.mirecle.com/2010/04/13/php-in-the-set-names-and-mysql_set_charset.html' rel='bookmark' title='Permanent Link: php中set names与mysql_set_charset'>php中set names与mysql_set_charset</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mirecle.com/2010/01/19/on-the-web-javascript-chinese-garbled.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
