I am trying to convert an HTML string to base64 which I will then display in an iframe but I am running into some issues. When I encode the string as base64 and view it as a data URI, it is display non-breaking spaces as 'Â', and other characters such as apostrophes and dashes are displayed as random ASCII characters.
This is how I am converting the string to base64:
var blob = new Blob([message], {
type: contentType
});
var reader = new FileReader();
reader.onload = function (e) {
let result = e.target.result;
};
reader.readAsDataURL(blob);
Any ideas on how to prevent this? Thanks!