fix character encoding

This commit is contained in:
Wirlaburla 2023-01-08 23:59:24 -06:00
parent 5218286e53
commit d205bafebc

View File

@ -78,8 +78,9 @@ function startStation(new_station) {
// Start player using IcecastMetadataPlayer for the metadata. // Start player using IcecastMetadataPlayer for the metadata.
// Use ?+date for avoiding problems with cache. // Use ?+date for avoiding problems with cache.
tuner.player = new IcecastMetadataPlayer(new_station.listen_url+"?"+Date.now(), { tuner.player = new IcecastMetadataPlayer(new_station.listen_url+"?"+Date.now(), {
onMetadata: (metadata) => {updateMetadata(metadata.StreamTitle);}, onMetadata: (metadata) => {updateMetadata(metadata.StreamTitle.decodeHTMLEntity());},
metadataTypes: ["icy"] metadataTypes: ["icy"],
icyCharacterEncoding: "iso-8859-1"
}); });
// Start new context with analysers // Start new context with analysers
@ -868,4 +869,15 @@ window.addEventListener('DOMContentLoaded', (event) => {
} }
updateXHR(); updateXHR();
}); });
String.prototype.decodeHTMLEntity = function() {
// As much as I don't want to do this... it works I guess.
var t = document.createElement('a');
t.innerHTML = this;
return t.innerText;
/* As much as I want to use this, it causes some issues with emojis
return this.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
}); */
}