File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -122,12 +122,12 @@ <h2 class="entry-title"><a href="/blog/2016/306.html" rel="bookmark">PHP中Notic
122122 < div class ="entry-content ">
123123 < p > 今天在写一个导出数据到csv的功能,为了防止中文乱码,需要将utf8转码,我使用了这样的语句:</ p >
124124< div class ="codeText ">
125- < pre class ="prettyprint linenums:1 "> #这里先是把csv文件的内容生成,然后下面转码
125+ < pre class ="prettyprint linenums:1 "> #这里先是把csv文件的内容生成,然后下面转码
126126$csv=iconv('utf-8','gb2312',$csv);</ pre >
127127</ div >
128128< p > 结果报< span style ="color: #ff0000; "> < strong > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> Notice: </ span > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> iconv():</ span > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> </ span > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> Unknown</ span > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> </ span > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> error</ span > < span style ="font-family: arial; font-size: 13px; line-height: 20.02px; "> (22)</ span > </ strong > </ span > < span style ="color: #333333; font-family: arial; font-size: 13px; line-height: 20.02px; "> 的错误,想起来$csv里带有换行,所以没办法转换,于是在各个数据项串成csv文件内容前转换,这时报了两个</ span > < span style ="color: #ff0000; "> < strong > iconv(): Unknown error (84)</ strong > </ span > 的错误,输出内容,发现报错时有一个是处理汉字“密菓”,第二个字不认得,生僻,我突然想到,难道是字符集不支持,于是换成gbk:</ p >
129129< div class ="codeText ">
130- < pre class ="prettyprint linenums:1 "> $csv .= iconv('utf-8','gbk',$val)
130+ < pre class ="prettyprint linenums:1 "> $csv .= iconv('utf-8','gbk',$val)
131131</ pre >
132132</ div >
133133< p > 再运行,没报错了。</ p >
@@ -678,7 +678,7 @@ <h2 class="screen-reader-text">文章导航</h2>
678678
679679 < div class ="site-info ">
680680 < span class ="site-title "> < a href ="/ " rel ="home "> 网站建设技术集锦</ a > </ span >
681- < a href ="https://cn.wordpress.org/ "> 自豪地采用WordPress</ a >
681+ < a href ="https://cn.wordpress.org/ "> 自豪地采用WordPress</ a > < p > Hosted by < a href =" https://pages.coding.me " style =" font-weight: bold " > Coding Pages </ a > </ p >
682682 </ div > <!-- .site-info -->
683683 </ footer > <!-- .site-footer -->
684684 </ div > <!-- .site-inner -->
You can’t perform that action at this time.
0 commit comments