Encoding


.NET Core WebUtility.UrlEncode or HttpUtility.UrlEncode

When we are dealing with URL encode in .NET Core 2.1, there are two APIs: System.Net.WebUtility.UrlEncode and System.Web.HttpUtility.UrlEncode. What's the difference between them? And which one should we prefer to use? I have done some research today, here's my findings. 1. Test Results First, let's see some tests. I've tested 2 couples of the same method between WebUtility class and …


Use GB2312 encoding on Windows Phone 8

如果你在WP开发中遇到过中文乱码,多数原因就是编码问题。比如用webclient获取远程网页的内容,如果目标网页是GB2312编码的,那你取得的很可能是乱码。就像这样: 虽然webclient的构造函数支持传递编码方式进去,但WP默认Encoding枚举中没有GB2312编码: 聪明的你可能会用Encoding.GetEncoding(“GB2312”)强撸,结果灰飞烟灭: 好在这个问题已经有高手给解决了。只要添加这三个文件到项目中去就能直接使用。 big5.bingb2312.binDBCSEncoding.cs 这些文件在我的SkyDrive共享上都能下载到。https://skydrive.live.com/?mkt=zh-CN#cid=E0A43B71445444C5&id=E0A43B71445444C5!10177 之后, …