PDA

查看完整版本 : 請教亂碼的問題


哈啦
2007-06-23, 12:22 AM
我有一個文件,很奇怪,那個文件執行時,所有填上中文的都可以順利顯示,唯獨裡面一塊「內容簡介」裡填上中文,出來時卻成為亂碼?整個網站都已採utf-8編碼,不知為何會出這種狀況?

文件如下,紅色那塊出來的內容,填上中文會成為亂碼:
{include file="header.tpl"}
{literal}
<script>
function checkform()
{
if (document.video.titletext.value == '') {
alert('Please Enter A Title');
return false;
}
else if (document.video.descriptiontext.value == '')
{
alert('Please Enter A description');
return false;
}
else if (document.video.authortext.value == '')
{
alert('Please Enter A Author');
return false;
}
else if(!document.video.picture[0].checked && !document.video.picture[1].checked && !document.video.picture[2].checked) {
alert('Please Choose A Screenshot');
return false;
}
// If the script gets this far through all of your fields
// without problems, it's ok and you can submit the form

return true;
}</script>
{/literal}
<div align="center">
<form action="submit.php?pt=submit&amp;part=3" method="post" name="video" onSubmit="return checkform()">
<!--Center Page-->
<h3><b>Source</b>:{$source}
</h3>
<!--Source Of Media-->
<b>Confirm Default Screenshot</b>
<input name="videoid" type="hidden" value="{$videoid}" />
<input name="vidtype" type="hidden" value="{$vidtype}" />
<input name="file2" type="hidden" value="{$file2}" />

<table width="136" border="0">
<!--Shows All The Images-->
<tr> {section name=default loop=$image}
<td align="center" width="130"><img src="{$image[default]}" alt="{$title}" width="130" height="97" /> </td>
{/section} </tr>
<tr> {section name=default loop=$image}
<td align="center"><input name="picture" type="radio" value="{$image[default]}" checked="checked" />
</td>
{/section} </tr>
</table>
<!-- END - Shows All The Images-->
<table width="83" border="0">
<tr>
<td height="21" align="center"><b>Title</b></td>
</tr>
<tr>
<td height="21" align="center"><textarea name="titletext" cols="50" rows="1" id="titletext" style="text-align:center; text-shadow:#990000">{$title}</textarea></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="77" height="21" align="center"><b>Author</b></td>
</tr>
<tr>
<td height="42"><textarea name="authortext" cols="50" rows="1" style="text-align:center;">{$author}</textarea> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="21" align="center"><b>內容簡介</b></td>
</tr>
<tr>
<td height="104"><textarea name="descriptiontext" cols="50" rows="6" style="text-align:center;">{$description}</textarea> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="19" align="center"><b>Category</b></td>
</tr>
<tr>
<td height="104" align="center"><select name="category" size="6">


{section name=cat loop=$cat}
<option value="{$cat[cat].id}" {if $cat[cat].id eq "1"}selected="selected"{/if}>{$cat[cat].name}</option>
{/section}



</select> </td>
<td>&nbsp;</td>
</tr>
</table>
<p align="center">{include file="players.tpl"} </p>
<p align="center">
<input type="submit" value="Submit">
</p>
</form>
</div>
{include file="footer.tpl"}

琉璃仙人
2007-06-23, 01:01 AM
另存为utf-8 无bom就可以了~

哈啦
2007-06-23, 01:10 AM
另存为utf-8 无bom就可以了~


什麼意思?之前這個文件我已用emeditor以utf8編碼存檔,因此其中的中文「內容簡介」顯示在網頁上就是中文無誤。

琉璃仙人
2007-06-23, 09:47 AM
一般我们使用UltraEdit-32 对于文件编译完,选择另存为,如果是utf-8格式,含有中文,里面有一个utf8无bom格式。
这是因为我们一般中文会在函数里面产生多余bom影响显示

琉璃仙人
2007-06-23, 09:49 AM
{include file="header.tpl"}
{literal}
<script>
function checkform()
{
if (document.video.titletext.value == '') {
alert('Please Enter A Title');
return false;
}
else if (document.video.descriptiontext.value == '')
{
alert('Please Enter A description');
return false;
}
else if (document.video.authortext.value == '')
{
alert('Please Enter A Author');
return false;
}
else if(!document.video.picture[0].checked && !document.video.picture[1].checked && !document.video.picture[2].checked) {
alert('Please Choose A Screenshot');
return false;
}
// If the script gets this far through all of your fields
// without problems, it's ok and you can submit the form

return true;
}</script>
{/literal}
<div align="center">
<form action="submit.php?pt=submit&amp;part=3" method="post" name="video" onSubmit="return checkform()">
<!--Center Page-->
<h3><b>Source</b>:{$source}
</h3>
<!--Source Of Media-->
<b>Confirm Default Screenshot</b>
<input name="videoid" type="hidden" value="{$videoid}" />
<input name="vidtype" type="hidden" value="{$vidtype}" />
<input name="file2" type="hidden" value="{$file2}" />

<table width="136" border="0">
<!--Shows All The Images-->
<tr> {section name=default loop=$image}
<td align="center" width="130"><img src="{$image[default]}" alt="{$title}" width="130" height="97" /> </td>
{/section} </tr>
<tr> {section name=default loop=$image}
<td align="center"><input name="picture" type="radio" value="{$image[default]}" checked="checked" />
</td>
{/section} </tr>
</table>
<!-- END - Shows All The Images-->
<table width="83" border="0">
<tr>
<td height="21" align="center"><b>Title</b></td>
</tr>
<tr>
<td height="21" align="center"><textarea name="titletext" cols="50" rows="1" id="titletext" style="text-align:center; text-shadow:#990000">{$title}</textarea></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="77" height="21" align="center"><b>Author</b></td>
</tr>
<tr>
<td height="42"><textarea name="authortext" cols="50" rows="1" style="text-align:center;">{$author}</textarea> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="21" align="center"><b>內容簡介</b></td>
</tr>
<tr>
<td height="104"><textarea name="descriptiontext" cols="50" rows="6" style="text-align:center;">{$description}</textarea> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="19" align="center"><b>Category</b></td>
</tr>
<tr>
<td height="104" align="center"><select name="category" size="6">


{section name=cat loop=$cat}
<option value="{$cat[cat].id}" {if $cat[cat].id eq "1"}selected="selected"{/if}>{$cat[cat].name}</option>
{/section}



</select> </td>
<td>&nbsp;</td>
</tr>
</table>
<p align="center">{include file="players.tpl"} </p>
<p align="center">
<input type="submit" value="Submit">
</p>
</form>
</div>
{include file="footer.tpl"}

琉璃仙人
2007-06-23, 09:52 AM
http://img405.imageshack.us/img405/9396/56581441jt3.jpg

哈啦
2007-06-23, 11:36 AM
http://img405.imageshack.us/img405/9396/56581441jt3.jpg


這是哪一版的ultraedit?我目前用的ultraedit32 11.00a+版找不到這個選項,能把這個選項所在的工具列位置弄個screenshot給我看嗎?thanks

琉璃仙人
2007-06-23, 12:57 PM
這是哪一版的ultraedit?我目前用的ultraedit32 11.00a+版找不到這個選項,能把這個選項所在的工具列位置弄個screenshot給我看嗎?thanks

http://img108.imageshack.us/img108/1134/30592356rn7.jpg

哈啦
2007-06-23, 02:33 PM
奇怪,我的「另存為」只有以下的畫面?

http://img513.imageshack.us/img513/2246/21157450ec5.gif

caicaimaopk
2007-06-23, 06:43 PM
1 乱码的页面 右键看源代码 看看charset是不是utf-8
2 tpl本身是否是utf-8
或者干脆把这个tpl就改成四个汉字 內容簡介 看它還是不是亂的

哈啦
2007-06-23, 07:29 PM
1 乱码的页面 右键看源代码 看看charset是不是utf-8
2 tpl本身是否是utf-8
或者干脆把这个tpl就改成四个汉字 內容簡介 看它還是不是亂的

按了確實都是utf-8,而同頁有正確顯示的中文,就這個部份亂碼。而且這些中文和出來的亂碼全是在同一個頁面裡填上去的東西,出來後卻大不同?

http://img466.imageshack.us/img466/7415/36328627vu0.gif

琉璃仙人
2007-06-24, 01:14 AM
那你试试gb2312

哈啦
2007-06-24, 02:09 AM
那你试试gb2312


沒有用,問題似乎不是出在編碼,用大五或簡體碼都一樣。:whoknows

caicaimaopk
2007-06-24, 07:20 AM
还是先把tpl改为几个中文字看看是否乱码 如果不乱码了 就检查另外里面包含include的tpl的编码

waikit86
2007-06-24, 08:47 AM
我都懷疑是tpl裡有問題

EmEditor儲存時不要加BOM
http://i14.tinypic.com/4ysp45c.gif