查询字符串转换%E1到%ufffd [英] QueryString converting %E1 to %ufffd

查看:382
本文介绍了查询字符串转换%E1到%ufffd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一个URL以下

I have a URL like the following

http://mysite.com/default.aspx?q=%E1

其中,%E1 应该是 A 。当我打电话的Request.QueryString 从我的C#网页我收到

Where %E1 is supposed to be á. When I call Request.QueryString from my C# page I receive

http://mysite.com/default.aspx?q=%ufffd

它这样做是任何重音字符。 %E1,E3%,%E9,%ED 等方面都获得通过的%ufffd 。普通EN codeD值(%2D %2E %27 )都得到正确地传递。

It does this for any accented character. %E1, %E3, %E9, %ED etc. all get passed as %ufffd. Normal encoded values (%2D, %2E, %27) all get passed correctly.

该配置文件已经有的ResponseEncoding / requestEncoding 在设置为UTF-8的全球化部分。

The config file already has the responseEncoding/requestEncoding in the globalization section set to UTF-8.

我怎么能读取正确的价值观?

How could I read the correct values?

请注意,我不是一个生成的查询字符串,我有没有对其进行控制。

Please note that I'm not the one generating the query string and I have no control over it.

推荐答案

虽然这是事实, A 为en codeD作为的 U + 00E1 ,使用UTF-8编码(也就是相关的URL参数)是 0xC3 0xA1

While it's true that á is encoded as U+00E1, the UTF-8 encoding (which is relevant for URL parameters) is 0xC3 0xA1.

您可以通过称为维基百科条目上的重音字母,如 HTTP验证:// en.wikipedia.org/wiki/%C3%81

You can verify by called a Wikipedia entry on an accented letter, such as http://en.wikipedia.org/wiki/%C3%81

U + FFFD 是统一code替换字符这表明一个给定的字符值不能被正确连接codeD中的Uni code。

U+FFFD is the Unicode Replacement Character which indicates the a given character value cannot be correctly encoded in Unicode.

更新:

您的问题有两点。

首先:我如何连接codeA统一code字符串作为参数。使用

First: How do I encode a Unicode string as parameter. Use

"?q=" + HttpUtility.UrlEncode(value)

二:我如何检索统一code值?用途:

Second: How do I retrieve a Unicode value? Use:

Request["q"]

如果您收到%E1 从其他来源你不用管,也许RawUrl可以帮助你。 (我没试过)

If you receive the %E1 from some other source you do not control, maybe the RawUrl can help you. (I have not tried)

这篇关于查询字符串转换%E1到%ufffd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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