我可以在HTTP标头中使用Unicode字符吗? [英] Can I use Unicode characters in HTTP headers?

查看:237
本文介绍了我可以在HTTP标头中使用Unicode字符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP标头是否仅限于US-ASCII字符集?

Is HTTP headers limited to US-ASCII charset?

我可以在HTTP标头中使用unicode字符吗?

Can I use unicode characters in HTTP headers?

修改

我想这样做:

WebClient myWebClient = new WebClient();
myWebClient.Headers.Add("Content-Type","یونیکد");


推荐答案

首先,示例中的标题字段确实如此不允许你想要的东西;媒体类型名称是ASCII。

First of all, the header field in your example does not allow what you want; media type names are ASCII.

理论上,HTTP头字段值可以传输任何内容;棘手的部分是让所有各方(发送方,接收方和中间方)就编码达成一致。

In theory, HTTP header field values can transport anything; the tricky part is to get all parties (sender, receiver, and intermediates) to agree on the encoding.

因此,安全的方法是坚持使用ASCII ,并选择一个编码,例如 RFC 5987 中定义的编码。

Thus, the safe way to do this is to stick to ASCII, and choose an encoding on top of that, such as the one defined in RFC 5987.

这篇关于我可以在HTTP标头中使用Unicode字符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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