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

推荐订阅源

Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
Vercel News
Vercel News
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
T
Threatpost
Security Latest
Security Latest
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
I
Intezer
P
Privacy International News Feed
D
Docker
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
A
Arctic Wolf
IT之家
IT之家
S
SegmentFault 最新的问题
S
Securelist
博客园 - 叶小钗
N
News and Events Feed by Topic
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - Franky
GbyAI
GbyAI
AI
AI
Y
Y Combinator Blog
WordPress大学
WordPress大学
Latest news
Latest news
Microsoft Security Blog
Microsoft Security Blog
人人都是产品经理
人人都是产品经理
N
News | PayPal Newsroom
The Cloudflare Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
I
InfoQ

博客园 - wiseman

universal image loader在listview/gridview中滚动时重复加载图片的问题及解决方法 升级framework4.0后form认证票据失效的问题 vs2010下连接sql2000的一些问题 IIS ftp的一个问题:home directory inaccessible MS SQLServer2000 的孤立用户问题及解决. 服务器部署.NET 3.5的问题 愚蠢的错误 - wiseman - 博客园 VS2005项目迁移至VS2008初体验. Linux学习笔记:REHL AS4的上网配置,Http服务安装及配置,ftp服务的安装及配置 Linux学习笔记:需求和安装 通过了解MySpace的六次重构经历,来认识分布式系统到底该如何创建. WebService problem:The remote name could not be resolved 烦人的CommunityServer 简单的WEB程序压力测试. MS ASP.NET AJAX 1.0 Released! 用C#编写flash Application! 困扰了两天的问题... .NET2.0中Form验证的问题. 一句C#代码的分析.
Atlas提交中文时乱码的完整解决方案.
wiseman · 2006-11-22 · via 博客园 - wiseman

Ajax中最常出现的一个问题就是服务端的包含中文的Response被XmlHttp编码后变成乱码.Atlas中也同样存在这个问题.
这虽然不是什么大问题,但有时候确实很令人烦恼,现给出我的两个解决方案,有需要的朋友可以参照解决.

1).修改web.config编码为
<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>,若之前你的编码为gb2312,这次的改动可能会带来其他页面的乱码出现,那你只好整站统一utf-8编码

2).对提交字符串编码(推荐)

static string FormatEncode(string str)
        
{
            
byte[] buffer = System.Text.Encoding.Default.GetBytes(str);
            
return System.Text.Encoding.UTF8.GetString(buffer);
        }

用该方法对输入字符串格式化后再提交,则不会再出现问题.
此方法的好处在于无须修改页面编码,修改后出问题几率小;
缺点是每次提交进行一次编码,使性能下降.但是可以预计这种提交数据与展示相比肯定是要少的多,因此对性能的影响有限.