代码页 65001 和 utf-8 是一样的吗?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
上面的代码对吗?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Is the above code right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的。
UTF-8 在 Windows 中是 CP65001(这只是在旧代码页中指定 UTF-8 的一种方式)。据我所知,当指定这种方式时,ASP 可以处理 UTF-8。
Yes.
UTF-8 is CP65001 in Windows (which is just a way of specifying UTF-8 in the legacy codepage stuff). As far as I read ASP can handle UTF-8 when specified that way.
您的代码是正确的,尽管我更喜欢在代码中设置 CharSet 而不是使用元标记:-
代码页 65001 确实引用了 UTF-8 字符集。如果您的 asp 页面(以及任何包含内容)包含标准 ASCII 字符集之外的任何字符,您需要确保将它们保存为 UTF-8。
通过在 <%@ 块中指定 CODEPAGE 属性,您表明使用 Response.Write 写入的任何内容都应编码为指定的代码页,在本例中为 65001 (utf-8)。值得记住的是,这不会影响逐字发送到响应的任何静态内容。因此,文件需要使用指定的代码页实际保存。
响应的 CharSet 属性设置 Content-Type 标头的 CharSet 值。这对内容的编码方式没有影响,它只是告诉客户端正在接收什么编码。同样重要的是,他的值与发送的实际编码相匹配。
Your code is correct although I prefer to set the CharSet in code rather than use the meta tag:-
The codepage 65001 does refer to the UTF-8 character set. You would need be make sure that your asp page (and any includes) are saved as UTF-8 if they contain any characters outside of the standard ASCII character set.
By specifying the CODEPAGE attribute in the <%@ block you are indicating that anything written using Response.Write should be encoded to the Codepage specified, in this case 65001 (utf-8). Its worth bearing in mind that this does not affect any static content which is sent verbatim byte for byte to the response. Hence the reason why the file needs be actually saved using the codepage that is specified.
The CharSet property of the response sets the CharSet value of the Content-Type header. This has no impact on how the content my be encoded it merely tells the client what encoding is being received. Again it is important that his value match the actual encoding sent.
是的,65001 是 UTF-8 的 Windows 代码页标识符,如文档所述 在 Microsoft 网站上。
Wikipedia 还建议 IBM 代码页 1208 和 SAP 代码页 4110 也是 UTF-8 的指示符。
Yes, 65001 is the Windows code page identifier for UTF-8, as documented on the Microsoft website.
Wikipedia suggests also that IBM code page 1208 and SAP code page 4110 are also indicators for UTF-8.
当物理文件保存为 utf-8 时,似乎会给出不好的结果,
否则,它会按预期工作。
seem to give bad result when the physical file is saved as utf-8
Otherwise, it work as it is supposed to.