Using ISO-8859-1 in jQuery UI Header

I am changing an existing page encoded using ISO-8859-1, and I cannot change its encoding to UTF-8.

I am using jQuery UI Dialog to send information to the user.

Everything is fine, except for the fact that some buttons have accented characters below:

buttons: [ { text: "SIM!", click: function() { //'yes' button clicked } }, { text:'NÃO', click: function() { //'no' button clicked } } ] 

When I show the dialog, the "NÃO" button becomes "N & Atilde; O", but the browser ignores the html object and displays N & Atilde; O.

I also tried putting N & Atilde; O instead of NÃO, but did not work.

Is there a way to correctly display the accented character on the jQuery UI button?


UPDATE

After struggling with this problem all morning I saw what was happening ... CMS only exchanges javascript texts for HTML objects (this is the worst CMS I have ever seen). I solved the problem of creating a hidden div with the text that I wanted to put on the button and used it, instead of just placing the line as shown below:

front:

 buttons: [ { text: "SIM!", click: function() { //'yes' button clicked } }, { text:'NÃO', click: function() { //'no' button clicked } } ] 

after

  buttons: [ { text: "SIM!", click: function() { //'yes' button clicked } }, { text:$("#badcms").html(), click: function() { //'no' button clicked } } ] </script> (...) <div id="badcms" style="display:none">NÃO</div> 
+4
source share
5 answers

As suggested in the comments, I answer my question.


After dealing with this problem in one whole morning, I saw what was happening ... CMS only exchanges javascript texts for HTML objects (this is the worst CMS I have ever seen). I solved the problem of creating a hidden div with the text that I wanted to put on the button and used it, instead of just placing the line as shown below:

front:

 buttons: [ { text: "SIM!", click: function() { //'yes' button clicked } }, { text:'NÃO', click: function() { //'no' button clicked } } ] 

after

  buttons: [ { text: "SIM!", click: function() { //'yes' button clicked } }, { text:$("#badcms").html(), click: function() { //'no' button clicked } } ] </script> (...) <div id="badcms" style="display:none">NÃO</div> 
+1
source

You need to convert (transcode) the file from ISO-8859-1 to UTF-8. A good editor can do this (e.g. Notepad ++). Then just make sure the encoding is correctly declared (a substantial part of the transition to UTF-8).

+1
source

Why not encode the object?

 N&#195;O 
0
source

As .text deletes entities in any format, you can set the source text to text:'NAO' , then extract the button and update its html;

 $('.ui-dialog-buttonset').children('button:contains(NAO)').html("N&Atilde;O"); 

Although I suspect that subsequent button manipulations will be reset.

0
source

There is a solution for this in the jQuery-UI dialog box. Instead of using the "text" attribute, use the "html" attribute as follows:

 buttons: [ { html: "SIM!", click: function() { //'yes' button clicked } }, { html:'N&Atilde;O', click: function() { //'no' button clicked } } ] 
0
source

Source: https://habr.com/ru/post/1393809/


All Articles