Interested in the following:

The html encoding is set as utf-8, but part of the text on the page in win-1251. Is it possible to set win-1251 encoding for this text using html or js (or transcode to utf-8) For example:

<html> <head> <meta charset="utf-8"/> </head> <body> <h1>UTF-8 текст</h1> <ul> <li charset="win-1251">Win-1251 текст</li> </ul> </body> </html> 

With the text itself in a different encoding, nothing can be done, you can only statically change the "wrapper" of html around.

  • The first time I hear the browser display the content in two encodings at once :) - lampa
  • Yes, I also, but there is such a problem Maybe you can somehow convert js? There is a template engine that generates a document from a template, the template can be changed, but the input data is not. And they are part of the utf-8 part of win-1251. - Chad
  • Thought it over, thanks. I'll try, but I'm not sure what to turn out to convert to base64. Although probably it will be possible to simply generate iframe js'om. - Chad
  • one
    @ Chad, I think js can be recoded. In general, what is the problem, this is the solution;) - lampa
  • No, the transcoding hike does not turn out to be js ohm - if the encoding is not correct, it already falls into js as '?'. Sadness - Chad

1 answer 1

@ Chad you can probably part with a different encoding to make in the iframe? Those. it turns out:

 <html> <head> <meta charset="utf-8"/> </head> <body> <h1>UTF-8 текст</h1> <iframe src="data:text/html;base64,PGh0bWw+CjxoZWFkPgogIDxtZXRhIGNoYXJzZXQ9IldpbmRvd3MtMTI1MSIvPgo8L2hlYWQ+Cjxib2R5PgogIDx1bD4KICAgIDxsaSBjaGFyc2V0PSJ3aW4tMTI1MSI+V2luLTEyNTEg0YLQtdC60YHRgjwvbGk+CiAgPC91bD4KCjwvYm9keT4KPC9odG1sPg=="></iframe> </body> </html> / html; base64, PGh0bWw + CjxoZWFkPgogIDxtZXRhIGNoYXJzZXQ9IldpbmRvd3MtMTI1MSIvPgo8L2hlYWQ + Cjxib2R5PgogIDx1bD4KICAgIDxsaSBjaGFyc2V0PSJ3aW4tMTI1MSI + V2luLTEyNTEg0YLQtdC60YHRgjwvbGk + CiAgPC91bD4KCjwvYm9keT4KPC9odG1sPg =="> </ iframe> <html> <head> <meta charset="utf-8"/> </head> <body> <h1>UTF-8 текст</h1> <iframe src="data:text/html;base64,PGh0bWw+CjxoZWFkPgogIDxtZXRhIGNoYXJzZXQ9IldpbmRvd3MtMTI1MSIvPgo8L2hlYWQ+Cjxib2R5PgogIDx1bD4KICAgIDxsaSBjaGFyc2V0PSJ3aW4tMTI1MSI+V2luLTEyNTEg0YLQtdC60YHRgjwvbGk+CiAgPC91bD4KCjwvYm9keT4KPC9odG1sPg=="></iframe> </body> </html> 
  • And how can I add frame data without base64 encoding? - Chad
  • @ Chad of course you can: <html> <head> <meta charset = "utf-8" /> </ head> <body> <h1> UTF-8 text </ h1> <iframe id = 'frame'> </ iframe> <div id = 'hide'> <ul> <li charset = "win-1251"> Win-1251 text </ li> </ ul> </ div> <script> document.getElementById ('frame') .src = 'data: text / html; charset = win-1251,' + encodeURI (document.getElementById ('hide'). innerHTML); </ script> </ body> </ html> - lampa
  • No, it looks like it is not possible. It's a pity. - Chad
  • one
    @ Chad hmhm, and try to insert a frame with a link to the same page, replace the charset and remove all unnecessary from the frame! Suddenly prokanaet! - lampa