惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
B
Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
C
Check Point Blog
月光博客
月光博客
L
LangChain Blog
GbyAI
GbyAI

博客园 - openkava

我的天涯助手V1 微软asp.net 2.0 rdlc报表发布到虚拟主机上 - openkava 恶意脚本代码分析 - openkava - 博客园 自用aspx小工具 cmd.aspx v1.2 aspx最小代码连接数据库 数据库连接字符串 - openkava - 博客园 Jquery 使用笔记1 - openkava - 博客园 c# aspx 动态编译文件模板 - openkava test zz巧用三个SQL视图查出所有的数据库字典 01 DiscuzNT1.0安装 编写的一个简单的ashx小程序 用bat文件搞定文件的备份 zz习惯的力量:35岁以前养成好习惯 竟然有免费送书的好事啊 Log4Net 使用心得 .net remoting 传递令牌 zz一篇很好的编码原理的文章 comesmith 4.1 试用笔记-
c# 乱码解决方法 - openkava - 博客园
openkava · 2008-06-26 · via 博客园 - openkava

1 设置web.config
 
    <globalization
            requestEncoding="utf-8" 
            responseEncoding="utf-8"
            fileEncoding="utf-8"
    />

如果相应使用gb2312 ,则html页面也要设置相同,解决乱码。

如果为 utf-8 ,则相应的html文件的属性要转换成utf-8保存,这样
可以解决字符串变量赋值,输出的时候乱码问题。
2  不同编码转换
 byte[] b = System.Text.Encoding.UTF8.GetBytes(ss);

        System.Text.Encoding gb = System.Text.Encoding.GetEncoding("GB2312");

       string g = gb.GetString(b);

        Response.ContentType="text/html";     
          Encoding GB2312 = Encoding.GetEncoding("gb2312");
           Request.ContentEncoding =GB2312;  ;//GB2312;
          Response.ContentEncoding =GB2312;
3 使用HttpUtility.UrlEncode 进行对参数的转换
 获得原始参数
     string s =  Request.RawUrl.Split('=')[1];
      Response.Write(Server.UrlDecode(s));
4 <%@ Page language="c#"  codePage="65001"%> 设置页面编码