前端零碎知识

1.字符编码

  <system.web>
      <globalization requestEncoding="utf-8" responseEncoding="gbk" fileEncoding="utf-8" />

  </system.web>

  responseEncoding是实际影响请求头的配置,但设置为"gbk"后FireFox中的请求头为chareset=gb2132

  fileEncoding Specifies the default encoding for .aspx, .asmx, and .asax file parsing. Unicode and UTF-8 files that are saved with the byte order mark prefix are automatically recognized, regardless of the value for this attribute.

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

  charset 属性规定在外部脚本文件中使用的字符编码。如果外部文件中的字符编码与主文件中的编码方式不同,就要用到 charset 属性。

  ·提示:charset 属性可以通过任意元素上的 lang 属性来重写。

  ·注意:实测得知,Visual Studio在asp页面中根据charset解析用户定义的文档编码,如果文件真实编码与charset定义的不一致,则读入的文件会乱码。fileEncoding的默认编码此时不起作用

  ·在普通项目中属性中的编码设置在asp页面中转换到web.config文件中,这一点在按照普通项目思路解决问题时应注意

  ·utf with Bom不适合用在网页中,这个网页给出了解释:https://my.oschina.net/JKOPERA/blog/309423

  ·vs中自动将utf 替换成utf with BOM? 将.aspx .aspx.cs文件转为utf后编译不通过,转为utf-8可以

posted @ 2016-10-31 09:17  .viva  阅读(121)  评论(0)    收藏  举报