<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="http://www.majordojo.com/projects/FeedManager/atom.xsl" type="text/xsl" media="screen"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html" />
  <link rel="self" type="application/atom+xml" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html" />
  <id>tag:www.thinkjam.org,2009:/zoptuno//2/tag:www.thinkjam.org,2004:/zoptuno//2.66-</id>
  <updated>2009-09-21T03:18:44Z</updated>
  <title>Comments for 解决UTF-8编码VBB3附件下载名乱码</title>
  <subtitle>My think. My dream.</subtitle>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.31-zh-cn</generator>
  <entry>
    <id>tag:www.thinkjam.org,2004:/zoptuno//2.66</id>
    <link rel="alternate" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.thinkjam.org/loveblog/batom.cgi/weblog/blog_id=2/entry_id=66" title="解决UTF-8编码VBB3附件下载名乱码" />
    <published>2004-11-15T07:07:27Z</published>
    <updated>2008-11-07T16:36:04Z</updated>
    <title>解决UTF-8编码VBB3附件下载名乱码</title>
    <summary>使用UTF-8编码的VBB3论坛在下载中文附件时，在IE下会出现乱码，而在Fir...</summary>
    <author>
      <name>平生一笑</name>
      <uri>http://www.thinkjam.org/zoptuno</uri>
    </author>
    
    <category term="代码" />
    
    <content type="html" xml:lang="en" xml:base="http://www.thinkjam.org/zoptuno/">
      <![CDATA[使用UTF-8编码的VBB3论坛在下载中文附件时，在IE下会出现乱码，而在Firefox下正常，经过摸索，终于发现了解决方法，与诸君分享：<br /><br />]]>
      <![CDATA[打开attachment.php文件，查找：
<p>
<blockquote><font color="#000000">
<font color="#0000BB"> header</font><font color="#007700">(</font><font color="#DD0000">'Cache-control: max-age=31536000'</font><font color="#007700">);
<br />
</font><font color="#0000BB">header</font><font color="#007700">(</font><font color="#DD0000">'Expires: ' </font><font color="#007700">. </font><font color="#0000BB">gmdate</font><font color="#007700">(</font><font color="#DD0000">"D, d M Y H:i:s"</font><font color="#007700">, </font><font color="#0000BB">TIMENOW </font><font color="#007700">+ </font><font color="#0000BB">31536000</font><font color="#007700">) . </font><font color="#DD0000">' GMT'</font><font color="#007700">);
<br />
</font><font color="#0000BB">header</font><font color="#007700">(</font><font color="#DD0000">'Last-Modified: ' </font><font color="#007700">. </font><font color="#0000BB">gmdate</font><font color="#007700">(</font><font color="#DD0000">'D, d M Y H:i:s'</font><font color="#007700">, </font><font color="#0000BB">$attachmentinfo</font><font color="#007700">[</font><font color="#DD0000">'dateline'</font><font color="#007700">]) . </font><font color="#DD0000">' GMT'</font><font color="#007700">); 
<br /></font><font color="#0000BB"></font>
</font></blockquote></p>
<p>
在其后添加：</p>
<p>
<blockquote><font color="#000000">
<font color="#0000BB"> </font><font color="#007700">if (!isset(</font><font color="#0000BB">$isIE</font><font color="#007700">))
<br />&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static </font><font color="#0000BB">$isIE</font><font color="#007700">;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$isIE </font><font color="#007700">= </font><font color="#0000BB">iif</font><font color="#007700">(</font><font color="#0000BB">is_browser</font><font color="#007700">(</font><font color="#DD0000">'ie'</font><font color="#007700">), </font><font color="#0000BB">true</font><font color="#007700">, </font><font color="#0000BB">false</font><font color="#007700">);
<br />&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;&nbsp;
<br />if (</font><font color="#0000BB">$isIE</font><font color="#007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$attachmentinfo</font><font color="#007700">[</font><font color="#0000BB">filename</font><font color="#007700">] = </font><font color="#0000BB">iconv</font><font color="#007700">(</font><font color="#DD0000">"UTF-8"</font><font color="#007700">,</font><font color="#DD0000">"GBK"</font><font color="#007700">,</font><font color="#0000BB">$attachmentinfo</font><font color="#007700">[</font><font color="#0000BB">filename</font><font color="#007700">]);&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;} 
<br /></font><font color="#0000BB"></font>
</font></blockquote></P>
<p>
若没有iconv库，但是Linux主机，可以将后半部分替换为：</p>
<p>
<blockquote><font color="#000000">
<font color="#0000BB"> </font><font color="#007700">if (</font><font color="#0000BB">$isIE</font><font color="#007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$cmd </font><font color="#007700">= </font><font color="#DD0000">"echo '$attachmentinfo[filename]' | iconv -f UTF-8 -t GBK"</font><font color="#007700">;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$attachmentinfo</font><font color="#007700">[</font><font color="#0000BB">filename</font><font color="#007700">] = </font><font color="#0000BB">shell_exec</font><font color="#007700">(</font><font color="#0000BB">$cmd</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;} 
<br /></font><font color="#0000BB"></font>
</font></blockquote></P.]]>
    </content>
  </entry>

  <entry>
    <id>tag:www.thinkjam.org,2004:/zoptuno//2.66-comment:623</id>
    <thr:in-reply-to ref="tag:www.thinkjam.org,2004:/zoptuno//2.66" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html"/>
    <link rel="alternate" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html#c623" />
    <title>Comment from li3p on 2005-01-03</title>
    <author>
        <name>li3p</name>
<!--         -->
    </author>
    <content type="html" xml:lang="en" xml:base="">
	<![CDATA[<p>可以更进一步，根据客户端编码来调整iconv的参数。<br />
不然Big5或者日韩语系还会有问题。</p>]]>
    </content>
    <published>2005-01-03T12:48:44Z</published>
    <updated>2005-01-03T12:48:44Z</updated>
  </entry>

  <entry>
    <id>tag:www.thinkjam.org,2004:/zoptuno//2.66-comment:624</id>
    <thr:in-reply-to ref="tag:www.thinkjam.org,2004:/zoptuno//2.66" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html"/>
    <link rel="alternate" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html#c624" />
    <title>Comment from 007pig on 2005-07-14</title>
    <author>
        <name>007pig</name>
<!--         -->
    </author>
    <content type="html" xml:lang="en" xml:base="">
	<![CDATA[<p>用不着这么麻烦:)<br />
请参考:<br />
<a href="http://www.vbulletin-chinese.com/forum/showthread.php?goto=newpost&t=529" rel="nofollow"><a href="http://www.vbulletin-chinese.com/forum/showthread.php?goto=newpost&t=529" rel="nofollow"><a href="http://www.vbulletin-chinese.com/forum/showthread.php?goto=newpost&t=529" rel="nofollow">http://www.vbulletin-chinese.com/forum/showthread.php?goto=newpost&t=529</a></a></a></p>]]>
    </content>
    <published>2005-07-14T01:25:12Z</published>
    <updated>2005-07-14T01:25:12Z</updated>
  </entry>

  <entry>
    <id>tag:www.thinkjam.org,2004:/zoptuno//2.66-comment:625</id>
    <thr:in-reply-to ref="tag:www.thinkjam.org,2004:/zoptuno//2.66" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html"/>
    <link rel="alternate" type="text/html" href="http://www.thinkjam.org/zoptuno/archives/2004/11/eutf8ccvbb3eaea.html#c625" />
    <title>Comment from 平生一笑 on 2005-07-14</title>
    <author>
        <name>平生一笑</name>
<!--         -->
    </author>
    <content type="html" xml:lang="en" xml:base="">
	<![CDATA[<p>这样是可以，不过对付超过40个字符的附件时，同样会出现问题</p>]]>
    </content>
    <published>2005-07-14T12:58:45Z</published>
    <updated>2005-07-14T12:58:45Z</updated>
  </entry>

</feed>
