I have a one-page application that points to UTF-8 encoding with a "meta" tag in my head:
<head>
<meta charset="utf-8">
...
</head>
...
On the Reports page in the application, I use a table library that also exports the report as a CSV file. This library uses the encoding of the HTML page as the encoding for the exported CSV file, and this cannot be reconfigured. However, the CSV file must be imported using an outdated system that cannot understand UTF-8.
The approach that I tried to overcome this problem is to change the encoding (by changing the meta tag) each time I move to the report page / from it - this way the library will export to the encoding more suitable for an outdated application. I tried using angularjs and ng-ifas follows:
<head ng-controller="NavigationController">
<meta ng-if="!onReportsPage" charset="utf-8">
<meta ng-if="onReportssPage" charset="windows-1252">
...
</head>
I also tried to manually remove / add the meta tag as follows:
<head id="head">
<meta id="charset" charset="utf-8">
...
</head>
...
var head = document.getElementById('head');
var oldCharsetTag = document.getElementById('charset');
head.removeChild(oldCharsetTag);
var newCharsetTag = document.createElement('meta');
newCharsetTag.setAttribute('id', 'charset');
newCharsetTag.setAttribute('charset', 'windows-1252');
head.appendChild(newCharsetTag);
...
...
newCharsetTag.setAttribute('charset', 'utf-8');
...
angular/javascript POV , -, DOM, ( Chrome). - UTF-8, head. iframe, , . - ?
.
: , . - ? (angular -datatables) CSV .