如何修复资源文件中的西班牙重音问题?

How to fix spanish grave accent issue from resouce file?

多语言功能在来自资源文件的正常 html 页面中工作正常,但是当涉及到 javascript 时,它就失败了例如: 在 html 页面中,成功是西班牙语的“éxito”,它工作正常,但是当涉及到 javascript 时,它显示为 & #201;xito
如果我们在 javascript 中将 'éxito' 硬编码为字符串,它也可以工作,但是当从资源文件加载到 javascript 时,它会失败

function Login_Create_user(id) {

        $.ajax({
            url: '@Url.Action("CreateLogin", "User")',
            type: "POST",
            async: false,
            data: { studentId: Id },
            success: function(result1) {
                if (result1 == true) {
                    swal("@Resource.Success", "StudentLoginCreatedSuccessfully.", "success");
                    window.location.reload();
                } else if (result1 == false) {
                    swal("@Resource.warning", "@Resource.FailedtoCreatelogin ! @Resource.Pleasetryagainlater", "warning");
                } else {

                    swal("@Resource.warning", result1, "warning");
                }
            },
            error: function(ex) {

            }
        });
    }

我希望“éxito”从资源文件加载到 javascript

时应该加载为“éxito”

您可以使用以下任何函数解码 ajax 响应,使用纯 JavaScriptJquery

//Decode HTML-entities (JS)
function decodeHTMLEntities(text) {
  var textArea = document.createElement('textarea');
  textArea.innerHTML = text;
  return textArea.value;
}

//Decode HTML-entities (JQuery)
function decodeHTMLEntities(text) {
  return $("<textarea/>")
    .html(text)
    .text();
}


decodeHTMLEntities('&#201;xito')

output: "Éxito"