问题
I have a textBox. When I click mybtn if myTxtBox is empty a tooltip appears and give the message which attached to 'data-original-title'. It's working fine but when I add turkish charachters inside text instead of "Some text", these charachters are shown as a question mark.
$("#mybtn").on('click', function (e) {
if ($("#myTxtBox").val() == "") {
MyTooltipCreator("#myTxtBox");
$("#myTxtBox")
.attr('data-original-title', "Some text")
.tooltip('fixTitle')
.tooltip('show');
}
});
The strange thing is when I add my scripts inside my cshtml file it works very well. The problem occurs after I move my scripts into a seperate js file.
回答1:
If it is a static text then I think you need to change your js file Encoding Type.
Open your js file in Visual Studio. Click to "File" from top left corner. Then click to "Save as" your file. There is an arrow next to the "Save" button. Click to this arrow and select "Save with Encoding" and confirm the Save as process. In "Advanced Save Options" popup select Unicode(UTF-8) Encoding and click "OK".
来源:https://stackoverflow.com/questions/42158277/seperate-js-file-utf-8-not-working-in-asp-net-mvc-razor