Reputation: 252
I have script.js file that contains several string in cyrillic. When i attempt to load this with standart link like this:
<script type="text/javascript" src="~/Content/Script/Script.js"></script>
cyrillic letters become rectangulars/badCharsetCaracters.
This solves the broblem:
<script type="text/javascript" src="~/Content/Script/Script.js" charset="windows-1251"></script>
How can I set charset with ASP.NET MVC 4 Bundles? Code like this:
bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
"~/Content/Script/Script.js"));
Upvotes: 6
Views: 4849
Reputation: 4499
Change your script file's encoding to your website's encoding.
For example, if your site is encoded in UTF-8, then:
Upvotes: 3
Reputation: 139748
You can use the Scripts.RenderFormat to specify your custom script tag rendering format:
@Scripts.RenderFormat(
"<script type=\"text/javascript\" src=\"{0}\" charset=\"windows-1251\"></script>",
"~/bundles/scripts")
Upvotes: 12