简体   繁体   English

从包含瑞典语字符的模型字符串中设置javascript变量

[英]Setting javascript variable from model strings containing Swedish Characters

Newbie type question 新手类型问题

I have the following function to set a grids title and fields (dynamic grid) 我具有以下功能来设置网格标题和字段(动态网格)

网格标题功能

The Model variables can contain Swedish characters Model变量可以包含瑞典语字符

在此处输入图片说明

But when this is all passed to the client , the swedish characters look like this. 但是,当所有这些都传递给客户端时,瑞典语字符看起来像这样。

在此处输入图片说明

The Grid handles this fine, until it goes to export the Grid to Excel. 网格可以很好地处理此问题,直到将网格导出到Excel。 The columns are fine , but the titles are how the rendered function looks. 列很好,但是标题是呈现的函数的外观。 在此处输入图片说明

My assumption that this is caused because of the conversion happening when setting from the model variable. 我认为这是由于从模型变量进行设置时发生转换而引起的。

Appreciate any ideas people have :) 欣赏人们的任何想法:)

Razor is a HTML-rendering engine, and is HTML-escaping each @... substitution. Razor是HTML渲染引擎,并且在HTML中转义了每个@...替换。 If you know your content is HTML-safe, you can mark it so: 如果您知道您的内容是HTML安全的,则可以将其标记为:

field: "@Html.Raw(d.field)"

(and analogously for any other place where you are injecting content in JS strings and not in HTML). (并且类似地用于您以JS字符串而非HTML形式注入内容的任何其他地方)。

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

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