fix character encoding
This commit is contained in:
parent
5218286e53
commit
d205bafebc
16
radio.js
16
radio.js
|
@ -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
|
||||||
|
@ -869,3 +870,14 @@ 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);
|
||||||
|
}); */
|
||||||
|
}
|
Reference in New Issue
Block a user