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"));
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")
Change your script file's encoding to your website's encoding.
For example, if your site is encoded in UTF-8, then:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With