解码asp.net 4.0 - 特殊字符 [英] Decoding in asp.net 4.0 - Special Characters

查看:231
本文介绍了解码asp.net 4.0 - 特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net特殊字符按照W3C标准解码。 ASCII - URL编码图。一些特殊字符不被转换,而不是转换为?,请检查下面的问题,为92%,实际ASCII结果为`,我想实现这个脱code到一个URL编码字符相等。

  strurl =工人%92 +住宿;
字符串strde code = Server.UrlDe code(strurl);

例如:ASCII code 92%(按W3C standarards URL编码是 - 这是不存在的按键板指的 http://www.w3schools.com/TAGS/ref_urlen$c$c.asp )。


解决方案

您必须取消code。与适当的编码codePAGE。 //www.ascii-$c$c.com : HTTP引用p>


  

有8位ASCII表的几种不同的变化。根据下表为ISO 8859-1,也被称为ISO Latin-1的....


根据 http://en.wikipedia.org/wiki/Windows_$c$ c_page ,对于ISO Latin-1的codePAGE是 1252 。要取消code你的字符串,只要做到以下几点:

  strurl = Encoding.GetEncoding(1252)。
             的GetString(HttpUtility.UrlDe codeToBytes(%92));

decoding of a special characters in asp.net as per the W3C standards. ASCII - URL encoding chart. Some of the special characters are not being converted instead converting to "?", check the below issue, actual result for %92 ASCII is "`", I'm trying to achieve this to decode to a urlencoding equal character.

strurl="Workers%92+Accommodation";
string strdecode=Server.UrlDecode(strurl);

Ex: ASCII code %92 (as per W3C standarards url encoding is for ' - which is not there in key board refer http://www.w3schools.com/TAGS/ref_urlencode.asp).

解决方案

You have to decode with appropriate encoding codepage. Quoting from http://www.ascii-code.com:

There are several different variations of the 8-bit ASCII table. The table below is according to ISO 8859-1, also called ISO Latin-1....

According to http://en.wikipedia.org/wiki/Windows_code_page, codepage for ISO Latin-1 is 1252. To decode your string, simply do the following:

strurl = Encoding.GetEncoding(1252).
             GetString(HttpUtility.UrlDecodeToBytes("%92"));

这篇关于解码asp.net 4.0 - 特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆