简体   繁体   English

在ASP.NET页上显示Unicode文本

[英]Displaying unicode text on ASP.NET page

I have gone through my DB and code so far, I have hit a problem. 到目前为止,我已经遍历了数据库和代码,但遇到了问题。 For a particular enrty in my DB I pick up descriptions and tags (both are strings)for japanese language. 对于我的数据库中的一个特殊爱好,我选择了日语的描述和标签(均为字符串)。 Now, in a ASP.NET page,the description is shown fine but the tags which are japanese as well, are replaced with ? 现在,在ASP.NET页面中,说明显示得很好,但是日语的标记也被替换为?。 marks, what am I doing wrong here? 标记,我在这里做错了什么? The same page displays description fine but within a <div> , tags are replaced by ? 同一页显示的描述很好,但在<div> ,标记被替换为? marks. 分数。 The code is as follows 代码如下

string[] tags = (Html.Encode(Item.Tags)).Split(new Char[] {',','.'});

in a loop over tags i have 在我拥有的标签中循环

<% Html.Encode(tags)%> // This is not fine!

While for description I have 虽然为了说明我有

<% Html.Encode(Item.Description)%> // This is fine!

Are you encoding them twice? 您要对它们进行两次编码吗? Html.Encode(Item.Tags) and then Html.Encode(tags) Html.Encode(Item.Tags) ,然后是Html.Encode(tags)

It turned out to be problem in the stored procedure. 事实证明这是存储过程中的问题。 the variable storing the strings and returning them to ASP.NET had to be a nvarchar and rather was a varchar. 存储字符串并将其返回到ASP.NET的变量必须是nvarchar,而应该是varchar。 Fixed my problem in ASP.NET eventually. 最终解决了我在ASP.NET中的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM