显示国际文本
我希望创建一个 ASP.net 页面,该页面将具有 GridView 或 Repeater 等控件,并且此页面中显示的数据可以是 unicode 或 Utf-8 。 我真的很难显示希伯来语和一些亚洲语言等语言。
如何在 ASP.net 页面上显示任何类型的语言? 我已经尝试过元标记选项和 <@ Page> 设置编码的选项,但它不起作用。 我缺少什么?
I am looking to create an ASP.net page that will have a control like GridView or Repeater and the data to be displayed in this page can be either unicode or Utf-8 . I am really struggling to display languages like Hebrew and some asian languages.
How do I show any type of language on the ASP.net page?? I have tried the meta tag option and <@ Page> option to set encoding but its not working. What am I missing??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理想情况下,这一切都应该由您的环境透明地处理。 不幸的是,“环境”也给了你一些把事情搞砸的工具。
有两件事需要发生。 您的服务器需要知道它应该发送到客户端的编码,并且浏览器需要知道该编码是什么。 通常,IIS 设置为发出 UTF-8,这正是您想要的。
如果您通过诸如 http://web-sniffer.net/ 之类的方式查看某个页面的标题,您可以看到服务器告诉浏览器正在发送的内容。 您可以而且应该发送 HTML 元标记指定相同的编码 (UTF-8)。
您还可以在 web.config 中指定编码,并且可能在 ASP.Net 页面声明中指定编码。 然而,这应该是多余的。
只要您使用当前 http 上下文提供给您的编码,您就无需在任何服务器端编写器中指定此编码。
围绕从右到左的语言可能存在更多问题,可能需要额外的调整。
Ideally, this should all be handled transparently by your environment. Unfortunately, "the environment" also hands you several tools with which to mess things up.
Two things need to happen. Your server needs to know what encoding it is supposed to send to the client and the browser needs to know what that encoding is. Typically, IIS is set to emit UTF-8, which is exactly what you want, period.
If you view the headers of one of your pages via something like http://web-sniffer.net/, you can see what your server is telling the browser it is sending. You can and should also send along an HTML meta tag specifying the same encoding (UTF-8).
You can also specify the encoding in web.config and presumably, in the ASP.Net page declaration. However, this should be redundant.
There is no place you need to specify this encoding in any of your server side writers, as long as you use the ones handed to you by the current http context.
There are likely more issues surrounding the right-to-left languages that may require additional tweaks.
确保 Response.Charset = UTF-8。
Make sure that Response.Charset = UTF-8.