You are not accepting special characters via javascript

Asked

Viewed 26 times

0

I created a file _Scriptspartial and inside that file is javascript code.

Follows file _Layout:

<!DOCTYPE html>
<html>
<head>
    <partial name="_Favicons" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"]</title>
</head>
<body>
    <partial name="_ScriptsPartial" />
</body>
</html>

Follow the file code _Scriptspartial:

$('div.dropdown-menu')
    .append('<h1><span class="badge badge-secondary">Notificação</span></h1>');

See the result:

inserir a descrição da imagem aqui

This problem happens only by javascript code.

I already converted the encoding to utf-8 from the file _Scriptpartial and see VS2017 editor output:

inserir a descrição da imagem aqui

Some solution ?

  • 1

    What is the encoding of your file?

  • @lazyFox here is how ANSI, Visual Studio creates this default file.

  • 1

    Exchange for UTF-8.

  • @Augustovasques I’ll have to change the coding to UTF-8 using note block while creating new files from Visual Studio 2017 ?

  • Speaking of the generated html <head><meta charset="UTF-8"></head>.

  • @Augustovasques Here’s how <meta charset="utf-8" />

Show 1 more comment

1 answer

0

Change your file to use encoding utf-8.

See this link how to change encoding in Visual Studio
You can always use an external program to change the encoding such as Notepad++

  • Didn’t work, I converted to utf-8, from file _ScriptsPartial, Visual Studio editor itself did not recognize special characters.

  • Please look my asked, I just edited

  • I don’t use Visual Studio, but I doubt that the editor does not recognize the characters. You’ve already deleted the strange characters and rewritten now with the utf-8 encoding?

  • Deletes file and created again, apparently it is working normal with special characters. I went to look the encoding is like utf-8, do not know why in the previous file, VS2017 created with encoding ANSI, very strange. It would be a bug ?

  • It is possible or some preset of your IDE.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.